Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (3)
Collapse All/Expand All Collapse All
SPWebApplication..::.UpdateMappedPage Method

Updates the custom application page mapping.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Visual Basic (Declaration)
Public Function UpdateMappedPage ( _
    key As SPWebApplication..::..SPCustomPage, _
    newValue As String _
) As Boolean
Visual Basic (Usage)
Dim instance As SPWebApplication
Dim key As SPWebApplication..::..SPCustomPage
Dim newValue As String
Dim returnValue As Boolean

returnValue = instance.UpdateMappedPage(key, _
    newValue)
C#
public bool UpdateMappedPage(
    SPWebApplication..::..SPCustomPage key,
    string newValue
)

Parameters

key
Type: Microsoft.SharePoint.Administration..::.SPWebApplication..::.SPCustomPage
The application page to replace with the specified custom application page.
newValue
Type: System..::.String
The location of the custom application page. This must start with “/_layouts/”. To remove the mapping to the custom page, set the value to nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: System..::.Boolean
true if the custom application page is successfully mapped; otherwise, false.

The newValue parameter is restricted to a location in the /_layouts folder. When updating the mapped page, the URL has to start with “/_layouts/”.

The following code sample shows how to update the mapping from the default AccessDenied.aspx application page to a custom application page and display it to the console. The original application page is restored at the end.

C#
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace MapCustomAppPage
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://MyServer"))
            {
                //Get a reference to the web application.
                SPWebApplication webApp = site.WebApplication;

                //Update AccessDenied application page to AxsDnd.aspx.
                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/SubFolder/AxsDnd.aspx");
                webApp.Update();

                //Output the newly assigned application page.
                Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.AccessDenied));

                //Reset the mapping to the default application page.
                webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, null);
                webApp.Update();

                Console.Out.WriteLine("Press any key...");
                Console.ReadKey();
            }
        }
    }
}
Visual Basic
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration
Module Module1

    Sub Main()

        Using site As New SPSite("http://MyServer")
            'Get a reference to the web application.
            Dim webApp As SPWebApplication = site.WebApplication

            'Update AccessDenied application page to AxsDnd.aspx.
            webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/SubFolder/AxsDnd.aspx")
            webApp.Update()

            'Output the newly assigned application page.
            Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.AccessDenied))

            'Reset the mapping to the default application page.
            webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, Null)
            webApp.Update()

            Console.Out.WriteLine("Press any key...")
            Console.ReadKey()
        End Using

    End Sub

End Module
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Change Access Denied Page using Features      Rehan Anmol   |   Edit   |   Show History
See my post
http://www.anmolrehan-sharepointconsultant.com/2011/08/how-to-use-custom-access-denied-page-in.html
Tags What's this?: Add a tag
Flag as ContentBug
re moss 2007      Markos1   |   Edit   |   Show History
in moss you could look at using an HTTP handler (if you use iis7)
Tags What's this?: Add a tag
Flag as ContentBug
Similar Method in MOSS 2007      Gary G. Wang   |   Edit   |   Show History
I know SPWebApplication.UpdateMappedPage is a new method in MOSS 2010. Does MOSS 2007 have something similar so that we can map accessdenied.aspx page?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker