/* This file is the backing for the global.asax file and enables global web application exception handling sending all uncaught .NET exceptions to an e-mail addresses specified in the web.config file. ==Working with Global.asax== Like with ASP.NET documents, you want to keep your code away from your structure. The global.asax file is no different. This implementation for global.asax is actually so common that it's probably not only a good idea to keep the code separate, but also to keep the code in a separate assembly for reuse in other applications. The basic idea behind this file is simple: When there is an uncaught exception, report it. You do this simply by setting the HttpApplication 'Error' event to an event handler that will do something when an uncaught exception is thrown. In my case, I use my 'ExceptionMananger' class. Having this type of setup greatly improves application stability. You will get notified of an uncaught exception before even the end user finds out about it. This will give you the ability to send THEM an error reporting telling them that you are working in the problem. People love it when they don't have to do anything and when people work for them. Having this setup will definitely give you points with people (of course your boss will take all the credit anyhow-- but we should all get used to that). The 'ExceptionManager' class is part of my extremely minimal 'General' assembly. The 'ExceptionManager' class is basically a simple version of Microsoft's Exception Handling Application Block. At any point in the system, you can call the 'ExceptionManager' and you get an e-mail regarding some information of the internals of the system. I often find myself using this class when I'm working on a system that the Visual Studio debugger won't attach to, like a remote web service. If I don't have access to the other end and need internal information, I'll use this to send me information on each hit. Sometimes I'll even use it when attaching the debugger to ISS just isn't possible. */ using System; using System.Web; using General.ExceptionHandling; namespace Sample.Web { public class SampleHttpApplication : HttpApplication { public SampleHttpApplication( ) { this.Error += new EventHandler(SampleHttpApplication_Error); } void SampleHttpApplication_Error(object sender, EventArgs e) { HttpContext ctx = HttpContext.Current; ExceptionManager.Report("Uncaught Exception", ctx); } } }