Elmah正在努力捕捉未处理的异常。但是,在一个地方我使用以下代码手动记录错误,导致webapi操作导致异常。这个错误在某种程度上没有显示在elmah.axd
奇怪为什么?
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
这是我之前没有注意到的,登录调试窗口:
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)
更多关于问题的背景信息:
基本上,我在webapi中有一个action方法,它解析并处理来自sendgrid的传入电子邮件解析。如果发生任何类型的异常,则使用Azure中的ELMAH和Application Insights手动记录它。当ELMAH因上述错误消息而失败时,Application Insight日志记录将起作用。