是否有使用异常消息的方式来在ELMA滤波器异常?

例子:搜索 “System.Web.HttpException:请求超时”。我不希望过滤掉所有HttpException,但只有超时请求。结果 “System.Web.HttpException:超过最大请求长度。”

我不想做的就是为写自己的代码。因此,它是可以与所述的buildin-web.config配置?

要做到这一点

谢谢!

有帮助吗?

解决方案

当然可以。只需使用正则表达式来询问消息。见下面关于如何比较异常消息细节的示例中

<errorFilter>
  <test>
    <!-- http://groups.google.com/group/elmah/t/cbe82cee76cc6321 -->
    <and>
      <is-type binding='Exception'
               type='System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' />
      <regex binding='Exception.Message'
             pattern='invalid\s+viewstate'
             caseSensitive='false' />
      <regex binding='Context.Request.UserAgent'
             pattern='Trident/4(\.[0-9])*'
             caseSensitive='false' />
    </and>
  </test>
</errorFilter>

其他提示

您可以设置一个事件处理程序在你的Global.asax避免难看的配置正则表达式设置:

void ErrorMail_Filtering(object sender, Elmah.ExceptionFilterEventArgs e) 
{     
    if (e.Exception.Message.Contains("Request timed out"))
        e.Dismiss(); 
}

请参阅滤波误差

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top