Export (0) Print
Expand All

Building Block: Websites and Site Collections

SharePoint 2010

Last modified: April 22, 2011

Applies to: SharePoint Foundation 2010

In this article
Object Model for Websites and Site Collections
XML Used for Websites and Site Collections
Areas Related to Websites and Site Collection Development
More Information about Websites and Site Collection Development

This topic provides a brief overview of websites and site collections as development building blocks in Microsoft SharePoint Foundation.

SharePoint Foundation web applications contain one or more site collections. A site collection consists of a single top-level website with zero or more child websites, which can themselves have child websites.

A website is a collection of one or more pages and typically includes a set of lists, document libraries, content types, field (column) types, a set of available Features, a set of user alerts, and often a set of workflow instances. Websites also have an owner and a set of associated users and user groups. All of these types of entities can be programmatically added to (or removed from) a website. A website can also be the scope of a search.

A website can be created from either of two foundational entities: a site definition configuration or a web template, both of which are different types of XML markup.

A site collection is an administrative container of a hierarchy of one or more websites. Virtually all of the kinds of entities that are associated with a website can also be deployed at the level of the site collection in which case they are available for use in all the site collection’s websites. In addition, a site collection typically contains other types of entities that are shared by its websites. These include a set of Web Parts, a set of list templates, a set of themes, a set of workflows, and a set of Solutions that have been deployed in the site collection.

Site collections are the largest possible scope for a search in SharePoint Foundation, although broader search scopes are possible in Microsoft SharePoint Server. Site collections are the smallest unit for which there is a convenient backup and restore API. (However, lists and other more fine-grained units can be backed up and restored with the unattached database and database snapshot features. For more information, see Fine-grained Data Restoration from Unattached Database and Programmatic Administration of Database Snapshots.)

Each site collection has a site collection administrator.

Site collections and websites can be created programmatically. Each is represented by a class that has dozens of members that can be used to manage settings and child objects.

SPWeb Class

Websites are represented by objects of the SPWeb class. You can use members of this class to manage the following:

  • Look-and-feel of the website.

  • The website’s users and their permissions and alerts.

  • Web templates and configurations that are used to create subsites.

  • Galleries of list templates and Web Parts.

  • A variety of additional configuration settings.

Many of the properties are collections of the different kinds of child objects in the website such as its subsites, lists, list templates, and content types. Like many important classes, there is also a critical Update() method which commits changes to the SharePoint Foundation database.

There are a variety of ways to get a reference to an SPWeb object. For more information, see Getting References to Sites, Web Applications, and Other Key Objects.

SPSite Class

Site collections are represented by objects of the SPSite class. It also has members that can be used to manage child objects, including Features, subsites, Solutions, and event receivers.

There are multiple ways of getting a reference to an SPSite object. See Getting References to Sites, Web Applications, and Other Key Objects.

Note Note

Although the SPSite class represents site collections, it does not itself inherit from ICollection or ICollection<T>.

Important note Important

For both the SPWeb and SPSite classes, it is important that you know when to call their Dispose method and when not to. For more information, see Best Practices: Using Disposable Windows SharePoint Services Objects.

The Collaborative Application Markup Language (CAML) Site Schema markup is used to define site definitions. This markup is contained in two types of files.

  • A WebTemp*.xml file in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LCID\XML\, where LCID is the numerical ID of the language/culture such as 1033 for English. The markup in this file is mainly an itemization of site definition configurations and some information that you can use to make the configurations available for selection by users who are creating a new site in the SharePoint Foundation user interface (UI). For more information, see Understanding WebTemp*.xml Files.

  • An ONET.xml file in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\SiteType\XML\, where SiteType is the name of a site definition (a family of site definition configurations) such as ‘STS’ or ‘BLOG’. This markup provides metadata about the site type. It also itemizes and defines the lists, modules, and features that are part of the site type. For more information, see Understanding Onet.xml Files.

Note Note

New sites can also be created from a second kind of foundational structure called a web template to distinguish it from a site definition configuration. Web templates are also XML files. Specifically, they are a set of XML files within a solution (.wsp) file. A web template can be created in the UI or programmatically with the SaveAsTemplate(String, String, String, Boolean) method of the SPWeb class. The .wsp file that is created is stored in the content database. However, it can be downloaded from the solution gallery of the site collection’s top-level site and uploaded to another site collection’s gallery. For more information about web templates, see Web Templates.

Show:
© 2014 Microsoft