How to set custom error page in SharePoint 2013/2010

Place the custom error page at
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\
TEMPLATE\LAYOUTS\1033"

Code :- 

namespace UpdateErrorPage
{
   class Program
   {
      static void Main(string[] args)
      {
           using (SPSite site = new SPSite("http://siteUrl",SPUserToken.SystemAccount))
           {
              SPWebApplication webApp = site.WebApplication;
              webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, "/_layouts/15/1033/customerror.html"); 
              webApp.Update();

              Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.Error));
            
              //webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, null); //Reset Custom Error Page
              //webApp.Update();

              Console.Out.WriteLine("Press any key...");
              Console.ReadKey();
           }
       }
    }
}


Custom Error



Advertisements
This entry was posted in SharePoint and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s