Problem passing ELMAH log id to Custom Error page in ASP.NET
Posted
by Ronnie Overby
on Stack Overflow
See other posts from Stack Overflow
or by Ronnie Overby
Published on 2010-05-21T20:52:29Z
Indexed on
2010/05/25
16:21 UTC
Read the original article
Hit count: 401
I am using ELMAH to log unhandled exceptions in an ASP.NET Webforms application. Logging is working fine.
I want to pass the ELMAH error log id to a custom error page that will give the user the ability to email an administrator about the error. I have followed the advice from this answer. Here is my global.asax
code:
void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)
{
Session[StateKeys.ElmahLogId] = args.Entry.Id;
// this doesn't work either:
// HttpContext.Current.Items[StateKeys.ElmahLogId] = args.Entry.Id;
}
But, on the Custom error page, the session variable reference and HttpContext.Current.Items are giving me a NullReference exception. How can I pass the ID to my custom error page?
© Stack Overflow or respective owner