With SharePoint 2010 you can now set your own custom error pages by overriding out-of-box application pages like
AccessDenied.aspx, Confirmation.aspx, Error.aspx, Login.aspx, ReqAcc.aspx, SignOut.aspx etc. Various methods like UpdateMappedPage, GetMappedPage have been introduced to facilitate this.
Following are the Pages that you can override
| Page Name | Description |
| 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. |
Lets look at an Example to Override Existing Error.aspx with your Own custom page using UpdateMappedPage method.
Method -
UpdateMappedPage(SPWebApplication.SPCustomPage.pageName,yourCustomPage)
pageName - e.g. AccessDenied, Error, Login
yourCustomPage - This should be the url for your custom page in Layouts folder. This must start with “/_layouts/”. To remove the mapping to the custom page, set the value to null.
Return Value - This returns true if the custom application page is successfully mapped; otherwise, false.
Usage -
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, “/_layouts/CustomErrorPage/CustomErrorPage.aspx”);
To Remove the Mapping and reset to default -
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, null);
To get the Page currently being Used you can use the GetMappedPage method.
Method -
GetMappedPage(SPWebApplication.SPCustomPage.pageName or yourCustomPage Location)
pageName - e.g. AccessDenied, Error, Login
Custom Page Location- This should be the url for your custom page in Layouts folder. This must start with “/_layouts/”. To remove the mapping to the custom page, set the value to null.
Return Value - The location of the customized application page. Otherwise, null.
Usage –
webApp.GetMappedPage(SPWebApplication.SPCustomPage.Error)
or
webApp.GetMappedPage(“/_layouts/CustomErrorPage/CustomErrorPage.aspx”)



