Error Handling Template

Topic updated 4-7-2007

The Error Handling Template catches errors that may occur anywhere in your web application. Normally, when an unhandled exception occurs the user will be confronted with the standard ASP.NET page for unhandled exceptions. While informative to developers and system administrators, this will look ugly and confusing to end users.

aspnet_servererror

 

The Error Handling Template improves error handling in the following ways:

It replaces the standard ASP.NET error page with a custom error page that is more user-friendly
It adds logging of uncaught exceptions, preventing application errors to go undetected.

 

Adding the Error Handling Template

The Error Handling Template can be added by right-clicking the Extension Templates node in the Project Explorer, and choosing Add New ErrorHandlingTemplate from the context menu.

 

Logging options

Exceptions can be logged in various formats, including text files, email, database tables and the Windows Event Log. This is described in more detail in the Error Handling Options.

 

Implementation details

The template builds a class that implements HttpModule. In the Web.config this module handler is added as a web module handler.

 

<httpModules>

   <add type="GenWise.ErrorHandling.ErrorHandlingProvider,GenWise.ErrorHandling"

        name="ErrorHandlingProvider"/>

</httpModules>