Referencing SharePoint SPSite

The SharePoint SPSite us a collection of websites including top level sites and subsites under top website. The SPSite object is part of an SPSiteCollection object which in turn is a place holder for all site collections.

The SharePoint SPSite can be instantiate in two different ways

1. You can SPSite constractor such as:
SPSite oSiteCollection = new SPSite("SiteUrl");

2. You can use SPContext and its Site property:
SPSite oSiteCollection = SPContext.Current.Site;

The SharePoint SPSite is a collection of SPWeb objects and creation of the SharePoint SPSite will automatically create one SPWeb object. This web is then assigned to be a root web of the site. You can access this web via SPSite.RootWeb property for any object manipulations.

Featured pages