How to: Deploy an Application Page to Central Administration

Overview

In some situations, you might want to deploy an application page to the Central Administration Web site. For example, you might deploy a page that allows administrators to configure a timer job. This topic describes the steps you must perform to deploy the page to Central Administration.

For a practical example of the deployment of a custom application page to Central Administration, see the Farm Solution Reference Implementation. This uses a custom application page to configure a timer job.

Summary of Steps

This how-to topic includes the following steps:

  • Step 1: Create the SharePoint Project. In this step, you use the Microsoft® Visual Studio® development system to create a project that you can use to deploy and test your application page.
  • Step 2:Create a Mapped Folder. In this step, you create a SharePoint Mapped Folder that enables you to deploy your files to the correct location on the server file system.
  • Step 3: Add an Application Page. In this step, you add a simple application page to the mapped folder that you created.
  • Step 4: Create a Custom Action to Launch the Page. In this step, you create a feature manifest that defines a custom action. The custom action adds a navigation item to the Central Administration Web site.

Step 1: Create the SharePoint Project

This procedure creates a Microsoft SharePoint® project in Visual Studio 2010. You can use this project to build and deploy your application page.

To create a project

  1. Start Visual Studio 2010, and then create a new Empty SharePoint Project, as shown in the following illustration. Name the projectApplicationPage.

    Ff798467.cb1a9d08-de74-43ce-8c32-65e35d289e6c(en-us,PandP.10).png

  2. In the SharePoint Customization Wizard, specify a valid local site for debugging, select Deploy as a farm solution, and then click Finish.

    Note

    If you want Visual Studio 2010 to automatically activate your feature on the Central Administration Web site, set the local site to the URL of your Central Administration Web site.

    Ff798467.b0bd4869-3630-40ea-93ef-6e9eacb251f5(en-us,PandP.10).png

Step 2: Create a Mapped Folder

This procedure creates a SharePoint Mapped Folder. This makes it easy for you to deploy your files to a specific location on the server file system.

To create a mapped folder

  1. In Solution Explorer, right-click the project node, point to Add, and then click SharePoint Mapped Folder.

  2. In the Add SharePoint Mapped Folder dialog box, select the {SharePointRoot}\TEMPLATE\ADMIN folder, and then click OK.

    Ff798467.72bfe0d7-d939-4c1c-b800-1920c4f8a9e5(en-us,PandP.10).png

    Notice that Visual Studio has added an ADMIN node to Solution Explorer.

    Ff798467.8ac4ae0f-e13d-45c1-a3b0-387ce2c6314b(en-us,PandP.10).png

Step 3: Add an Application Page

This procedure creates a new application page and adds it to the ADMIN mapped folder.

To add an application page

  1. In Solution Explorer, right-click the ADMIN node, point to Add, and then click New Item.

  2. In the Add New Item dialog box, expand SharePoint in the Installed Templates pane, and then click 2010.

  3. Click Application Page, type a name for the page in the Name text box, and then click Add. This example uses the name SimplePage.aspx for the page.

    Ff798467.0e9ebcdf-2fff-4df6-b1c6-d88a280921d8(en-us,PandP.10).png

    Note

    In Solution Explorer, notice that Visual Studio has actually created a Layouts mapped folder and added the new page to that. This is the default behavior for application pages, and you must manually move the page to the desired location.

    Ff798467.9e5a6c2a-132a-47cb-b5ac-e957de073b64(en-us,PandP.10).png

  4. In Solution Explorer, drag the ApplicationPage folder from the Layouts mapped folder to the ADMIN mapped folder. You can now delete the Layouts mapped folder.

  5. Add some content to your application page. This example uses some HTML to verify that the page was deployed successfully.

    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" 
                 >
      <p>This is a simple application page</p></asp:Content>
    

Step 4: Create a Custom Action to Launch the Page

This procedure creates a feature manifest that defines a CustomAction element. The custom action adds a navigation item that enables administrators to launch your page from the Central Administration Web site.

To add a navigation item to Central Administration

  1. In Solution Explorer, right-click the project node, point to Add, and then click New Item.

  2. In the Add New Item dialog box, expand SharePoint in the Installed Templates pane, and then click 2010.

  3. Click Module, type a name for the module in the Name text box, and then click Add. This example uses the name NavItem for the module.

    Ff798467.420cf11c-4eb3-4568-83ff-3101c36b6735(en-us,PandP.10).png

  4. Expand the NavItem node and open the feature manifest file (Elements.xml). Delete the existing content, and then add the following XML. You can also delete the Sample.txt file from Solution Explorer.

    <Elements xmlns="https://schemas.microsoft.com/sharepoint/">
      <CustomAction Id="[GUID]" GroupId="TimerJobs" 
          Location="Microsoft.SharePoint.Administration.Monitoring" 
          Sequence="10" 
          Title="Simple Page" Description="">
        <UrlAction Url="_admin/ApplicationPage/SimplePage.aspx" />
      </CustomAction>
    </Elements>
    

    Note

    This markup adds a custom action to the Timer Jobs action group on Central Administration. In practice, this adds a link to our custom application page under the Timer Jobs heading. For more information about custom action locations, see Default Custom Action Locations and IDs on MSDN.
    If you reuse the code, replace [GUID] with a new GUID.

  5. In Solution Explorer, expand Features, right-click Feature1, and then click Rename. This example uses the name SimplePageFeature for the feature.

  6. In Solution Explorer, double-click SimplePageFeature to open the Feature Designer. Notice that the feature already contains your NavItem module.

  7. In the Feature Designer window, give the feature a friendly title. Leave the scope set to Web.

  8. Press F5 to deploy and test your solution.

  9. Browse to the Central Administration Web site, and then click Monitoring. Notice that a Simple Page link has been added under Timer Jobs.

    Ff798467.e9ae588a-7bc6-44a5-a325-fe7d3bc53065(en-us,PandP.10).png

  10. Click Simple Page, and then verify that your custom application page is displayed.

    Ff798467.467c9f2b-f11b-49b9-ab54-5d0fb7bc31f3(en-us,PandP.10).png