SPWebApplication.UpdateMappedPage Method
SharePoint 2010
Updates the custom application page mapping.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
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 null.
Return Value
Type: System.Booleantrue if the custom application page is successfully mapped; otherwise, false.
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.
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(); } } } }
Change Access Denied Page using Features
See my post
http://www.anmolrehan-sharepointconsultant.com/2011/08/how-to-use-custom-access-denied-page-in.html
http://www.anmolrehan-sharepointconsultant.com/2011/08/how-to-use-custom-access-denied-page-in.html
- 8/1/2011
- Rehan Anmol
Similar Method in MOSS 2007
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?
- 3/25/2010
- Gary G. Wang
- 3/25/2010
- Gary G. Wang