【发布时间】:2013-02-07 12:38:09
【问题描述】:
我们将ELMAH 用于我们的MVC asp.net 应用程序。
当任何exception 发生时,ELMAH 发送具有事件 ErrorMail_Mailing 的错误邮件,
我正在 Global.asax
中为此事件编写处理程序
并尝试从HttpContext.Current.Items 变量中读取值,但得到null exception。
任何解决方法请帮助。
我在这里应用 Scott 的建议:-
http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx
在 global.asax.cs 中,我试图在事件处理程序下方编写,我想在其中配置错误邮件的主题行,其中包含存储在我的 HttpContext.Current.Items
protected void ErrorMail_Mailing(object sender, Elmah.ErrorMailEventArgs e)
{
if (HttpContext.Current.Items["CustomerName"] != null)
{
e.Mail.Subject = "Error came to / " + HttpContext.Current.Items["CustomerName"] + " / Error Type: " +
e.Error.Type;
}
}
【问题讨论】:
-
欢迎来到 SO。 :) 你正在尝试在 Gloabal.asax 中编写处理程序?请输入一些代码。
-
我正在尝试实现以下博客中提到的相同目标:- scottonwriting.net/sowblog/archive/2011/01/06/… 谢谢,我也在更新我的问题。
标签: asp.net-mvc elmah httpcontext