Unexpected Application Pool Recycle when using custom error page with SharePoint

Recently I got involved in an interesting Support case where the application pool of a SharePoint web application recycled unexpectedly. During Analysis it became clear that the problem occurred due to a web.config setting which configured a custom error page for http 500 status code:

    <httpErrors errorMode=”Custom” existingResponse=”Auto”>
      <remove statusCode=”500″ subStatusCode=”-1″ />
      <error statusCode=”500″ prefixLanguageFilePath=””
         path=”../_layouts/CustomDirectory/Error500.html” responseMode=”ExecuteURL” />
    </httpErrors>

The problem is caused by the fact that when using responseMode=”ExecuteUrl” ASP.NET forwards the request internally to the html error page without properly initializing all settings that would be initialized when directly browing to the html page. This occurs because only part of the request to the Error500.html page passes only through parts of the ASP.NET Pipeline.

As SharePoint intercepts the request to identify if the Url points to an item in the SharePoint site collection investigates the settings and runs in an exception due to the fact that the settings are not properly initialized. This exception leads to the Recycling of the application pool.

The workaround for this issue is to change the responseMode attribute as follow: responseMode=”Redirect”. Redirect will cause an additional roundtrip to the browser to redirect to the error page rather than forwarding the request internally to the error page.

The adjusted web.config Fragment would look like this:

    <httpErrors errorMode=”Custom” existingResponse=”Auto”>
      <remove statusCode=”500″ subStatusCode=”-1″ />
      <error statusCode=”500″ prefixLanguageFilePath=””
         path=”../_layouts/CustomDirectory/Error500.html” responseMode=”Redirect” />
    </httpErrors>

2 Comments


  1. Hi Stefan,

    Thanks for this informative post. Is this applicable to MOSS 2007 farm too?

    Regards,

    Tapan

    Reply

  2. Hi Tapan,

    the answer is no.

    MOSS 2007 did not use the integrated Pipeline in IIS 7.

    Cheers,

    Stefan

    Reply

Leave a Reply to Stefan Goßner Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.