Handling custom HTTP error messages on IIS 7 by SharePoint 2010

HTTP errors are returned to the client when something goes wrong on the server. Error status codes are returned if the requested file isn't found (404), or due to coding errors in the web page (500), and due to temporary issues such as failed database connections (500). The most common errors are 404 (file not found) and 500 (application) errors.

Check the following list of IIS errors

  • 400 Error (bad request)
  • 401 Error (unauthorized)
  • 403 Error (forbidden)
  • 404 Error (not found)
  • 500 Error (internal server error)

How to Custom HTTP Errors?

To implement SharePoint support of the custom HTTP error you have to editing in WebConfig file by adding the below section inside <system.webServer> tag and then you can replace "/Pages/404.aspx" with your own dynamic page.

<httpErrors errorMode="Custom" existingResponse="Auto">
     <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" prefixLanguageFilePath="" path="/Pages/404.aspx" responseMode="ExecuteURL" />

Actually the important part in the above snippet code is in <httpErrors errorMode="Custom" existingResponse="Auto"> because if you are working in SharePoint Config file you have to add to the httpErrors element setting error mode to custom and this will inform IIS to you out custom page.  


This configuration is just supported in newest versions of IIS starting from IIS7