0

Elmah is working alright catching exceptions that are unhandled. However, in one place I am using the following code to manually log error incase a webapi action causes exception. This error is somehow not displayed in elmah.axd wonder why?

Elmah.ErrorSignal.FromCurrentContext().Raise(ex);

Here is something I didn't notice earlier, log in debug window:

Exception thrown: 'System.Web.HttpRequestValidationException' in System.Web.dll
System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (headers="...8241F for <x+152@mail....").
   at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
   at System.Web.HttpRequest.<>c__DisplayClass280_0.<ValidateHttpValueCollection>b__0(String key, String value)
   at System.Web.HttpValueCollection.EnsureKeyValidated(String key)
   at System.Web.HttpValueCollection.GetValues(Int32 index)
   at System.Collections.Specialized.NameValueCollection.Add(NameValueCollection c)
   at Elmah.Error.CopyCollection(NameValueCollection collection)
   at Elmah.Error..ctor(Exception e, HttpContext context)
   at Elmah.ErrorLogModule.LogException(Exception e, HttpContext context)

More Context to the question:

Basically, I have an action method in webapi which parses and processes incoming email parse from sendgrid. If any type of exception occurs, it is manually logged with ELMAH and Application Insights in Azure. Application Insight logging works while ELMAH is failing with the above error message.

Shyamal Parikh
  • 2,988
  • 4
  • 37
  • 78
  • Looks like you have a HTTP head containing HTML/XML or at least a value that can be understood as it. Could you debug the code and list all headers at the point just before manually logging the error? – ThomasArdal Mar 22 '17 at 15:45
  • Yes it may contain html as the error happens when parsing email html code. – Shyamal Parikh Mar 22 '17 at 18:07
  • Why do you need to include HTML as HTTP headers? There gotta me another way to do this. – ThomasArdal Mar 22 '17 at 18:14
  • I don't understand what you are pointing at? Sendgrid sends an inbound parse email request, which I am processing in action method of webapi. While execution if there is an exception, elmah fails to log manual raised exception with error mentioned in question – Shyamal Parikh Mar 23 '17 at 13:29
  • here you go https://stackoverflow.com/questions/7441062/how-to-use-elmah-to-manually-log-errors – Sulaiman Sadoon Sep 17 '19 at 08:09

0 Answers0