Responsive Ads Here

Wednesday, June 6, 2012

SPSite Vs SPWeb and SPWebApplication


SPSite Vs SPWeb and SPWebApplication
a. Farm (SPFarm class)
b. Web application (SPWebApplication class)
c. Site collection (SPSite class)
d. Site (SPWeb class)
e. List (SPList class)

For a quick reference:
  • SPSite is a site collection
  • SPWeb is an instance of a SharePoint Website (or "Site" from the UI), this includes subsites
  • SPWebApplication is an instance of an IIS Web Application that hosts SharePoint site collections


• Firstly, you will have to create a new Web Application. This is because the web application creates its own database. This means that the data is segregated from the other web applications allowing separate backups of the database, separate security policies for the web application and its content such as anonymous access etc.
• Secondly, you will then create the Site collection. There are many templates available for you to choose from. Explanations for these templates will require another blog all on its own!
• Thirdly, within the site collection, sites and sub-sites can be created.
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server.
SPSite Represents a collection of sites on a virtual server, including a top-level site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections on the virtual server.
    • SPSite Represents a collection of sites on a virtual server, including a top-level site and all its subsites.
    • Each SPSite object, or site collection, is represented within anSPSiteCollection object that consists of the collection of all site collections on the virtual server.
    • SPSite.OpenWeb Method: Returns the site that is located
      at the specified server-relative or site-relative URL.
 To return the current site collection, you can use :
SPSite site = SPContext.Current.Site;
To return the web site of the current request, you can use :
SPWeb web = SPContext.Current.Web;


Depending on the kind of solution you are developing, you use different entry points into the object model to obtain the appropriate objects(SPWebApplicationSPSite or SPWeb). Below is the graphical representation of the SharePoint Server Object Model hierarchy.
enter image description here

Farm Image


Site Architecture



No comments:

Post a Comment