Which is the best way to create a custom error page in SharePoint ?


Depends what you mean by "best". The easiest way: In your web.config file: in the <system.web> section, modify the customErrors element to:

<customErrors mode="On" defaultRedirect="/Pages/MyCustomErrorPage.aspx" />

  • i mean , i dont want standard sharepoint error page"page not found" page to come everytime . i need to have an error page designed seperately for my client and whenever there is any error the custom page shld be soming . – Nikhil J Dec 28 '10 at 4:40
  • The 404 page not found situation is a little different. First you need to modify the FileNotFoundPage of the SPWebApplication object and give it a new file name, which you can code in a feature or do with Powershell. SharePoint looks for this 404 page in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033 (assuming English locale) - you can't give it a full path or URL. – SPDoctor Dec 28 '10 at 10:36

Write a HttpModule to handle the onerror event, and redirect to the custom error page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.