Stefan Goßner

Senior Escalation Engineer for SharePoint (WSS, SPS, MOSS, SP2010) and MCMS

Unexpected Application Pool Recycle when using custom error page with SharePoint

Unexpected Application Pool Recycle when using custom error page with SharePoint

  • Comments 2
  • Likes

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>

Comments
  • Hi Stefan,

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

    Regards,

    Tapan

  • Hi Tapan,

    the answer is no.

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

    Cheers,

    Stefan

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
Raw Html Fix