Handling 404 and other errors with Sitecore items

Error handling is very important in any type of application. But it’s not only important to handle the error in the backend, it’s also very important to give a properly and easy to read feedback to the user. Sitecore provides a basic set of error pages (page not found (404), access denied (403) and layout not found (500)). But these pages are static and not adapted to the customer layout.

The most comfortable way of creating nice error pages is to have an item within Sitecore for each error. The item should be managed by authors in every language and could be different for each site in a multisite environment. There are several ways of doing this, mostly by adding a new pipeline processor and overriding the Context.Item (see Handling HTTP 404). But there is a better and easier way: My company Unic has written the Sitecore Error Manager module, which is doing all you need to show the error pages you want.

How does it work?

The Sitecore Error Manager does not directly interact with Sitecore, instead he overrides the Sitecore error pages. When Sitecore couldn’t resolve an item to an url, it creates a redirect to the notfound.aspx in the ExecuteRequest pipeline (the file is configured in the web.config node /sitecore/settings/ItemNotFoundUrl). The Sitecore Error Manager overrides this setting and points to a custom page. This page creates a http request to the configured item within Sitecore and responds the html markup from the item back to the user.

With this idea, each statuscode (including substatuscodes) could be handled. Error pages for handling 404, 403 and 500 are included, other could be added.

Detailed information about the features and the configuration can be found on the GitHub wiki. Because it doesn’t interact that much with Sitecore, it should compatible with almost every version of Sitecore (tested up to version 6.4.1).


The Sitecore Error Manager can be downloaded from the Sitecore Marketplace and installed over a Sitecore package. You can also download the source code and build the module manually. The source code is available at GitHub. Happy error handling :)

Note: This is a repost from our german written blog Sitecore Vibes.

Kevin Brechbühl

Senior Developer & Architect | C# & ASP.NET | Sitecore Technology MVP

comments powered by Disqus