我正在使用ELMAH在ASP.NET Webforms应用程序中记录未处理的异常.记录工作正常.
我想将ELMAH错误日志ID传递给自定义错误页面,该页面将使用户能够通过电子邮件向管理员发送有关错误的信息.我听从了这个答案的建议.这是我的global.asax代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
但是,在自定义错误页面上,会话变量引用和HttpContext.Current.Items给了我一个NullReference异常.如何将ID传递给我的自定义错误页面?