Login

How can I modify the way my site deals with 404-errors?

Versions: 4.0 - 4.70, FAQ number: 176, Old FAQ number: 10609

There are three methods of approach for dealing with 404-errors in EPiServer solutions. The following FAQ tries to explain the different approaches you might take when customizing the way your site deals with them.

Topics:

Through the IIS Through the built-in EPiServer error handling module

Through settings in the web.config file


Through the IIS

Important: The page you enter in the following dialog needs to be the URL to an .aspx page in order for Unified File System and virtual paths to function correctly. If you do not enter an .aspx page, the 404 error will be handled by the IIS instead of ASP.NET which means you would miss out on the benefits of the .NET Framework.

The first option is to use the built in IIS setting under the “Custom Errors” tab. Scroll down to 404 in the list and click “Edit Properties…”.

A new dialog, “Error Mapping Properties” appears, letting you choose between Default, URL and File. By setting the dropdown list to URL you can tell the IIS which .aspx page you want the server to show the visitor when he encounters a 404 error.

See the following figure:

 

Through the use of the built-in EPiServer error handler

This module overrides the 404-handling and displays an error message that cannot be altered. In administration mode you have the option to enable or disable detailed error output as well as supplying an e-mail address to receive reports when errors are encountered. For more information on the possibilities of EPiServer error handling, see the chapter “Configuration of EPiServer/Error Handling In EPiServer” in the Administrators Manual:

http://www.episerver.com/downloads/Documents/AdminManuals/English/Administrator%20Manual%204-60%20(English)%20Rev%20A.pdf

 

Through Settings in the Web.config File

You can enable custom error handling in the web.config as well as telling the site which page to show when encountering file not found errors by setting the redirect attribute of an error element in the <customErrors> section. See the following example:

<customErrors mode="On" defaultRedirect="error.htm">

  <error statusCode="404" redirect="filenotfound.aspx"/>

</customErrors>

 

Note: web.config settings only apply to pages that are handled by the .NET Framework. If a visitor would try to visit a non existing .htm file, this would be handled by the IIS and not the web application.

For more information on the possibilities of EPiServer error handling, see the chapter “Configuration of EPiServer/Error Handling In EPiServer” in the Administrators Manual:

http://www.episerver.com/downloads/Documents/AdminManuals/English/Administrator%20Manual%204-60%20(English)%20Rev%20A.pdf

EPiTrace logger