views:

61

answers:

1

I've got an error page here SiteError.aspx and it's configured correctly in the web.config to go there when unhandled exceptions are encountered.

I want to use this page to log the exception that triggered it as well because I only want to LOG the errors that the users encounter (i.e. if SiteError.aspx is ever hit.)

This is the code I Have:

In the OnLoad(...) in SiteError.aspx

    Exception lastEx = Context.Server.GetLastError();
    if (lastEx != null)
        log.Error("A site error was encountered", lastEx);

However, my log is never showing up in my Output, and If i breakpoint on line 2 (in this example) code execution is never interupted (after letting the exception clear to ASP.NET handling in the debugger.

+1  A: 

This might help you. http://support.microsoft.com/kb/306355

See section "How to use the Web.config file"

I think you'll need to add a Global.asax to your project and handle the error in the Application_Error method.

Germ
So the redirected page is never given the error it's called for?
Aren
I've only ever used a redirect to control what is presented to the user. The exception handling is done in the error handler.
Germ