How to Change System Application Pages (Like AccessDenied.aspx, Signout.aspx etc)
        Posted  
        
            by Jayant Sharma
        on Geeks with Blogs
        
        See other posts from Geeks with Blogs
        
            or by Jayant Sharma
        
        
        
        Published on Tue, 10 Jul 2012 06:14:43 GMT
        Indexed on 
            2012/07/10
            15:16 UTC
        
        
        Read the original article
        Hit count: 392
        
An advantage of SharePoint 2010 over SharePoint 2007 is, we can programatically change the URL of System Application Pages. For Example, It was not very easy to change the URL of AccessDenied.aspx page in SharePoint 2007 but in SharePoint 2010 we can easily change the URL with just few lines of code.
For this purpose we have two methods available:
- GetMappedPage
 - UpdateMappedPage: returns true if the custom application page is successfully mapped; otherwise, false.
 
You can override following pages.
| Member name | Description | |
|---|---|---|
| None | ||
| AccessDenied | Specifies AccessDenied.aspx. | |
| Confirmation | Specifies Confirmation.aspx. | |
| Error | Specifies Error.aspx. | |
| Login | Specifies Login.aspx. | |
| RequestAccess | Specifies ReqAcc.aspx. | |
| Signout | Specifies SignOut.aspx. | |
| WebDeleted | Specifies WebDeleted.aspx. | 
So now Its time to implementation,
using (SPSite site = new SPSite(http://testserver01))
 {
   //Get a reference to the web application.
   SPWebApplication webApp = site.WebApplication;
   webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/customPages/CustomAccessDenied.aspx");
   webApp.Update();
 }
Similarly, you can use SPCustomPage.Confirmation, SPCustomPage.Error, SPCustomPage.Login, SPCustomPage.RequestAccess, SPCustomPage.Signout and SPCustomPage.WebDeleted to override these pages.
To reset the mapping, set the Target value to Null like
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, null);
webApp.Update();
One restricted to location in the /_layouts folder. When updating the mapped page, the URL has to start with “/_layouts/”.
Ref:
- http://msdn.microsoft.com/en-us/library/gg512103.aspx#bk_spcustapp
 - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.updatemappedpage.aspx
 
© Geeks with Blogs or respective owner