Call up last exception on an ASP.NET error page.
- by Aren B
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.