We are using ELMAH
for our MVC asp.net
application.
When any exception
occurs ELMAH
sends error mail which has an event ErrorMail_Mailing,
I am writing handler for this event inside my Global.asax
and trying to read value from HttpContext.Current.Items
variable but getting null exception
.
Any work around please help.
I am applying what Scott is suggesting here:-
http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx
In global.asax.cs I am trying to write below event handler, where I want to configure subject line of error mail with something stored inside my 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;
}
}