Sitefinity Custom Errors

Unsurprisingly we had to do some Error handling for a project. A colleague of mine had found this option

	<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="Redirect">
	  <remove statusCode="404" />
	  <remove statusCode="500" />
	  <error statusCode="404" path="/404" responseMode="ExecuteURL" />
	  <error statusCode="500" path="/500" responseMode="ExecuteURL" />
	</httpErrors>

Which works very nicely. Just make sure that you go to Sitefinity > Pages > add a 404 page and a 500 page and look sooooo pretty!!

But wait! Unfortunately this also handles the errors that Sitefinity thrown when you have I don’t know accidentally attempted to create an item with the same URLNAME. Instead of alert error showing that says “IIS 500 – you cannot have a duplicate urlname” it will say nothing! and continue on it’s merry way without you knowing that your item did not in fact get added.

To make it so you can see the errors thrown by Sitefinity’s backend make sure that you also add a web.config to your /Sitefinity folder directory ( ~/Sitefinity/web.config ) and add this code.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed">
            <clear/>
        </httpErrors>
    </system.webServer>
</configuration>

It will clear your custom  error page preferences and show you the raw error message. If you want this to be done on your server only errorMode=”DetailedLocalOnly” .

For more information on httpErrors go to http://www.iis.net/configreference/system.webserver/httperrors

 

Leave a comment

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