Saturday, February 7, 2009

Differnce between Asp.net and Sharepoint safe mode parser

When a request is comes for an .aspx page Sharepoint ISAPI takes care about who will serve the request. Asp.net or Safemode parser(sharepoint).Before this you should know the concept of sharepoint ghosted and unghosted pages.In sharepoint some pages are lie in physical folder of server i.e, _layouts or _vti_bin folder. These pages are accessible for all applications.These pages are call ghosted pages.If we edit these pages through designer or through front page 2003 the pages become unghosted and a copy of each page is stored in the application content database. To make it clearghosted pages are those rows in the docs table which have null values for the Content column and a non-null value for the SetupPath column which points to a file on the file system itself. The referenced file essentially serves as a template and content source.Any webpart page or normal pages are ghosted by default.
The main difference between Asp.net and sharepoint pareser is, in asp.net for each first request of the page is compiled into assembly, and next request onwards the compliled page gets executed. In sharepoints safe mode parser is not compiled. They are interpretative pages. Remember its not possible to make unghosted page to its original ghosted pageSo if there is any inline server code in aspx page the safe mode parser will not allow the page to load

Limitation of enabling session state

By default in Sharepoint session state is disabled. when you open any site collection web.config file you will see below line commented in http module
'add name="Session" type="System.Web.SessionState.SessionStateModule" '
The difference between session state in sharepoint and .net
In .net session can be enabled at page level. So the pages which doen't have the session can avoid the performance hit associated with it.But in sharepoint once the sessionstate is enabled for the application, all the the unghosted(customized) page forced to use sessionstate whether or not controls on that page require session state.
For ex: Assume your SharePoint server contains mostly unghosted pages. Let’s say there are 1000 unghosted pages on the site. You create a web part that requires session state. Let’s say that web part is only used on a few select pages (i.e. 2-3 pages). Enabling session state so that 2-3 pages can use the web part suddenly slows down the performance of the 998 other pages.SSo it is advisable not to use session state in sharepoint which degrades the performance of the application