Build a Really Useful ASP.NET Exception Engine
Sunday, July 8th, 2007http://www.eggheadcafe.com/articles/20030816.asp
Excerpt:
“The GetLastError() method of the Server object returns a reference to a generic HttpException wrapping the original exception that was passed from your ASP.NET page to the Application_Error event. Gain access to the original exception by calling its GetBaseException() method. This will provide the original exception instance, regardless of how many layers have been added to the exception stack. Once Application_Error has completed, it automatically performs a redirect to your custom error page that you can set up in web.config. See the MSDN documentation on how to set this up if you want it.”