Application Pool Recycle when using custom error page with SharePoint

Symptoms

You configure a custom error handler for the 500 status code in the web.config using code like the following:

    <httpErrors errorMode="Custom" existingResponse="Auto">
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" prefixLanguageFilePath="" path="../_layouts/CustomDirectory/Error500.html" responseMode="ExecuteURL" />
</httpErrors>
When browsing to an Url without file extension to a not existing item you experience an unexpected recycling of the application pool. 

Cause

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 browsing to the html page. As SharePoint intercepts the request to identify if the Url points to an item in the site collection, it verifies the settings and runs into an exception due to the fact that the settings are not properly initialized. This exception leads to the recycling of the application pool.

Resolution

Change the responseMode attribute web.config entry to responseMode="Redirect":

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

Id. de artículo: 2786672 - Última revisión: 10 dic. 2012 - Revisión: 1

Microsoft SharePoint Foundation 2010, Microsoft SharePoint Foundation 2013, Microsoft SharePoint Server 2010, Microsoft SharePoint Server 2010 Service Pack 1, Microsoft SharePoint Server 2013

Comentarios