Pages

Jun 20, 2011

Application Vs. Content Pages in SharePoint


Today my friend posted a simple question but might be tricky, so i thought to post it will be useful for interviews.
SharePoint has two types of ASPX pages. One type is the application page, also known as a _layout page. The other type of ASPX page is a content page, also known as a site page. Each of these page types is stored in a different location in SharePoint. When developers create custom ASPX pages, they must decide on the page type.
Content Pages or Site Pages:
Content pages or Site pages are basically built to display and manage site content. Content pages can be customized by end users from within the SharePoint user interface or with Microsoft Office SharePoint Designer. When you create a SharePoint site, many content pages are created automatically, for example, home page (default.aspx) of the as well as the pages associated with lists and document libraries, such as AllItems.aspx, NewForm.aspx, and EditForm.aspx, and several others. Logically all content pages are stored within their SharePoint sites. Physically all the content pages that have not been customized, also known as uncustomized or ghosted pages, are stored on disk on the front-end Web server, while content pages that have been customized, also known as customized or unghosted pages, are stored in their associated SharePoint content database.
Content pages do not support in-line server side code under the default security policy enforced by Windows SharePoint Services. But there is a way to override the WSS settings to allow the in-line server side code in content pages. But even after overriding WSS settings, the in-line server side code will be supported on content pages only if that content page is not customized.
Application Pages or _layout Pages:
Application pages or _layout page are basically built for site management activities. Application pages does not support customization and typically created to allow users to manage settings for lists, sites, and site collections. Application pages are stored typically in the file system of the front-end Web server within a directory "c:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\LAYOUTS". settings.aspx, viewlsts.aspx, etc. are few examples of application pages which you can find in the layouts directory.
Application pages are available across the server farm which allows these pages to run on any site collection in the farm. When you create a new SharePoint web application, it creates a new website in the IIS. If you look at the created website in the IIS, you can see that SharePoint automatically created a virtual directory name "_layouts" which is mapped to the physical LAYOUTS directory i.e. "c:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\LAYOUTS". By using this mapping scheme along with some additional processing logic, the WSS runtime can make each application page accessible within the context of any site in the farm.
An application page, such as settings.aspx, can be accessed by adding its relative path within the _layouts directory to the end of a site’s URL. For example, you can access the Site Setting page by using the URL "http://sitename.com/_layouts/settings.aspx".
Application pages, unlike content pages, supports in-line server side code but cannot host SharePoint features such as dynamic Web Parts and Web Part Zones.

No comments: