Dealing with 500 errors in Sitecore 8,7,6

5/21/2018 sitecore sitecore-handling-errors sitecore-best-practises

This is how to deal with 500 response code errors in Sitecore 8, 7, 6 versions correctly.

Step 1: Add below to sytem.web section in web.config file :

    <customErrors defaultRedirect="~/Error/500.aspx" mode="RemoteOnly" redirectMode="ResponseRewrite">
	    <error statusCode="500" redirect="~/Error/500.aspx"/>

Above code deals with runtime errors. Make sure it is a .aspx extension but not .html as IIS has some issue dealing with .html extensions on 500 errors.


Step 2: Add below to sytem.webServer section in web.config  :

    <httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto">
			<remove statusCode="500" subStatusCode="-1"/>
			<error statusCode="500" path="~/Error/500.html" responseMode="File"/>

Above code deals with any IIS errors.

Now add 500.html and 500.aspx to your build according to your project requirements.

Please let me know if u have any questions about this, i will come back as soon as i can.