Application Pages in SharePoint
Application pages are used to support application implementations in SharePoint Foundation. Application pages are stored on the file system of the front-end Web server in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS directory and exist for every site in a Web application. This folder is mapped to an Internet Information Services (IIS) virtual directory called _layouts. Every site and subsite will have access to the application pages by using the _layouts virtual directory. For example,http://myserver/_layouts/settings.aspx andhttp://myserver/subsite/_layouts/settings.aspx access the same application page on the front-end Web server unlike site pages, which is an instance for the specified site?
Application pages are not subject to the same restrictions as site pages. They allow in-line code without restriction. They cannot, however, use dynamic Web Parts or Web Part zones or be modified using SharePoint Designer. Modifying the default application pages is not supported in SharePoint Foundation. Custom application pages can be added to a subdirectory inside the _layouts folder.
Application Pages Vs Site Content Pages Vs Custom aspx Pages
Application Pages: An application page is deployed once per Web server and cannot be customized on a site-by-site basis. Application pages do not support customization, which gives them a few distinct advantages over site pages.
- Application pages are not tracked in the content database.
- They never run in safe mode and they can contain inline code.
- Each application page is always compiled into a single assembly DLL so that it performs and scales better than site pages that can be customized.
- Since application pages must be deployed inside the SharePoint Root directory, they cannot be used within sandboxed solutions. If you are required to build a SharePoint solution that targets the sandbox, the only type of page that you can add to a site is a site page
They stay in 12/14 hive folder structure, mostly under layouts folder and are used by all the sites and site collections for that server
They do support code behind and inline scripts
They do not inherit websites current master page. They will always inherit from application. master.
Site Pages: These are pages that make up the site interface and are specific to one site or site collection. Site pages support page customization through the browser and with SharePoint. Examples of site pages include the home page (default.aspx) for a site, as well as the pages associated with lists and document libraries, such as AllItems.aspx, NewForm.aspx, and EditForm.aspx
Customized site pages run in safe mode and, consequently, do not support inline code. To process the request for a customized site page, SharePoint Foundation must retrieve the content of pages from across the network in the content database. SharePoint Foundation must also parse each customized site page individually, as well as execute it in a special no-compile mode.
Since each customized page instance must be loaded separately into memory, it will affect the performance of large server farm.
They mostly get stored in the content database of the site collection
They do not support code behinds. We can only add Web Part zones to the site pages
They inherit the custom look and feel of the site.
Custom aspx Pages: These are the pages that are added via feature and\or solution package for a specific purpose or function.
If deployed in Layouts folder the remain uncustomized thus do not get stored in the Content database.
They can have a code behind and inline scripts. The code behind file is not deployed though
They do inherit the Look and feel of the site they are deployed in. You will have to specify the url of the Custom master page while deploying them.
Developers usually deploy them in Layouts folder.
Creating Custom Application Page using Visual Studio 2010
Creating Empty SharePoint Project:
Creating Empty SharePoint Project:
- Open Visual Studio 2010.
- Go to File => New => Project.
- Select 2010 from the installed templates SharePoint and choose Empty SharePoint Project.
Name it as CustomApplicationPage.
- Click Add.
- Enter the SharePoint server farm URL.
- Select 'Deploy it as a Farm Solution".
- Click Finish.
Adding Application Page:
- Right click the Solution Explorer and select Add a new item.
Select Application Page from the installed templates SharePoint and name it as CustomApplicationPage.
Aspired to become an SharePoint? Explore the post to discover the know-hows on SharePoint training course.
- Once you add the application page it will automatically create the Layouts Folder.
- In the solution explorer you could see Layouts -> CustomApplicationPage ->CustomApplicationPage.aspx.
- Once you deploy the solution the pages will be automatically placed in the 14 hive layouts folder.
- Open CustomApplicationPage.aspx from the solution explorer.
- In the "PlaceHolderMain" add one asp label control.
- And change the "PlaceHolderPageTitle" content to 'My Application Page" as shown in the following code.<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"Assembly="Microsoft.SharePoint, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI"Assembly="System.Web.Extensions, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=126.96.36.199, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true"CodeBehind="CustomApplicationPage.aspx.cs"Inherits="CustomApplicationPage.Layouts.CustomApplicationPage.CustomApplicationPage"DynamicMasterPageFile="~masterurl/default.master" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead"runat="server">
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">My Application Page
<asp:Label runat="server" Text="My Custom Page"></asp:Label>
<asp:Content ID="PageTitleInTitleArea"ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
My Application Page
- Build the solution.
- Deploy the solution.
- Go to the http://servername:2010/_layouts/CustomApplicationPage/ CustomApplicationPage.aspx.
A new custom application page has been created in SharePoint 2010 as shown below.
For Indepth understanding of SharePoint click on