Pages

Thursday, June 28, 2012

SPWebApplication Vs SPSite Vs SPWeb

SPWebApplication Vs SPSite Vs SPWeb

































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

SPWebApplication Definition :
-----------------------------------------------
Physically, SPWebApplication represents an IIS load-balanced website containing a custom web.config and a standard set of SharePoint specific files and virtual directories including the *_layouts* directory and the *_controltemplates* directory .


To get reference to target Web Application, you can use :


Uri webAppUrl = new Uri("http://sp2010site");
SPWebApplication webApp = SPWebApplication.Lookup(webAppUrl);



SPSite and SPWeb Definition :
---------------------------------------------------


SPSite and SPWeb are fundamental types in the Server Object Model. They represent a site collection and a website, respectively.


By and large, To work with SharePoint from a browser-based application, your code must first establish the site context or site collection context for requests sent to the server. 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;


Reference URL :
http://sharepoint.stackexchange.com/questions/23241/getting-my-head-round-spsite-vs-spweb-vs-anything-else
http://sridharu.blogspot.in/2008/02/spsite-vs-spweb-and-spwebapplication.html
http://point2sharepoint.blogspot.in/2011/03/spweb-vs-spsite-vs-spwebapplication_29.html




No comments:

Post a Comment