Dealing with 500 errors in Sitecore 8,7,6

Tags:     sitecore-handling-500-errors, sitecore-error, sitecore-best-practises

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

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

Above code deals with asp.net 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  :

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

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.