0

Currently I get an error email from ELMAH similar to the following screenshot, which is all good.

enter image description here

But one thing that is missing is a full url something similar to what you get from a Request.Url.ToString() (ie including domain,path and query). I'd like to know if there is an easy way to include the full request url which caused the error somewhere in the email title or the beginning of the body.

Currently I've to manually piece together the url from different request headers(domain, path and query) to know the incident site.

I'm aware of different global.asax hooks elmah provide, if something can be done in any of those events, I'd like to know from where I can grab an instance of the HttpContext or something to pull additional details from and add to the email body. But if there is any existing built in configuration option to include this info, that would be a better bet I guess.

ArunPratap
  • 4,816
  • 7
  • 25
  • 43
Mat J
  • 5,422
  • 6
  • 40
  • 56

1 Answers1

1

Actually it was simple. It was me ignoring the obvious. Simply add this handler in the Global.asax and you are done.

protected void ErrorMail_Mailing(object sender, Elmah.ErrorMailEventArgs e)
{
   e.Mail.Body = Context.Request.Url.ToString()+ "\r\n" + e.Mail.Body;
}
Mat J
  • 5,422
  • 6
  • 40
  • 56