In SharePoint,SPSite object also referred to as ‘site’, is actually a site collection object,not a website. SpWeb object also referred to as ‘web’, is actually a single site in the site collection.
SPWebApplication is the highest level object which has reference to the web application that contains the site collection.
To get the reference to site context in your code, use Microsoft.Sharepoint.SPContext class and its members.
1. To Reference a site collection: SPSite oSiteCollection=SPContext.Current.Site;
2. To Reference a Website: SPWeb oWeb=SPContext.Current.Web;
The basic SharePoint server object model hierarchy is graphically represented as shown below.
The basic SharePoint server object model hierarchy is graphically represented as shown below.