Call up last exception on an ASP.NET error page.
Posted
by Aren B
on Stack Overflow
See other posts from Stack Overflow
or by Aren B
Published on 2010-05-11T22:21:25Z
Indexed on
2010/05/11
22:24 UTC
Read the original article
Hit count: 387
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.
© Stack Overflow or respective owner