ASP.NET vs. SharePoint: Page Development

Applies to: SharePoint Foundation 2010

This topic points out the most important differences between webpage development in Microsoft ASP.NET 3.5 and in Microsoft SharePoint Foundation.

Application Pages and Site Pages

Among webpages, SharePoint Foundation makes distinctions that are unknown in ASP.NET. To begin with, SharePoint Foundation divides webpages into two broad categories: Application pages and Site pages. There are significant differences in the processes of developing the two types.

Application Pages

Application pages are the most similar to traditional Microsoft ASP.NET 3.5 webpages. However, an application page is not directly derived from System.Web.UI.Page. Instead, it is derived from either LayoutsPageBase or UnsecuredLayoutsPageBase.

Application pages are stored in the file system of the SharePoint Foundation servers in a virtual directory of the SharePoint Foundation web application that is accessible from every website in the web application. Hence, application pages are shared among the websites of a web application.

Perhaps the most crucial difference that developers must be aware of is that application pages do not run in safe mode and can contain inline code. This relaxation of security is possible because application pages can only be installed by a farm administrator.

As a general rule, application pages in a SharePoint Foundation typically have a lot of server controls and relatively little informational content as compared with Site pages.

Site Pages

Site pages tend to be content-oriented. Welcome pages, home pages, and list view pages are all examples of site pages. However, a site page can be highly functional and contain interactive web controls and Web Parts.

End users can create and add site pages to SharePoint Foundation websites. For this reason, there are significant restrictions on the code that can run in site pages. Specifically, site pages run in safe mode. This means that the only controls that are rendered on a site page are those that are registered as safe controls. Strictly speaking, a site page can contain inline code, but such code works only if the page is compiled. Some pages may be set to not compile by default. Moreover, one of the great advantages of using SharePoint Foundation is that its site pages can be customized. When a page is customized, it is no longer compiled, and inline code within it no longer works. For these reasons, we recommend against including inline code in site pages. ("Inline code" refers to embedded code that runs on the server. ECMAScript (JavaScript, JScript) that runs on the client can be used on any kind of page.) There are two kinds of site pages:

  • Standard pages: These are wiki-enabled pages that can include web controls and inline Web Parts. A standard page derives from the WikiEditPage class, not directly from System.Web.UI.Page.

  • Web Parts pages: As the name suggests, these are Web Parts pages with Web Part zones. A SharePoint Foundation Web Parts page derives from WebPartPage, not directly from System.Web.UI.Page.

For more information about custom page development in SharePoint Foundation see Building Block: Pages and User Interface and the Sites and Pages in SharePoint Foundation node of this SDK.

Master Pages and Content Pages

SharePoint Foundation makes heavy use of the ASP.NET master page technology. Both application pages and site pages are content pages that reference a master page. For more information about the use of master pages in SharePoint Foundation, see the Master Pages node of this SDK.

Mobile Pages

SharePoint Foundation mobile pages are much simpler than non-mobile pages. They do not use the ASP.NET master page/content page technology. Nor are they divided into application pages and site pages. SharePoint Foundation mobile pages are all application pages, and they are located in the \_layouts\Mobile folder. There is one respect in which a SharePoint Foundation mobile page is more like a site page: if the page contains a mobile Web Part adapter, the adapter must be registered as a safe control or it is not rendered. For more information about developing with mobile pages, see the Overview of Mobile Pages and the Redirection System node of this SDK.

See Also


SafeControl Element (Solution)


Building Block: Pages and User Interface

Master Pages

Overview of Mobile Pages and the Redirection System

Other Resources

Sites and Pages in SharePoint Foundation