gpt4 book ai didi

Elmah 错误过滤器

转载 作者:行者123 更新时间:2023-12-03 00:13:22 29 4
gpt4 key购买 nike

我在 web.config 中有一个 Elmah 过滤器设置,用于停止某些错误消息的通知。但他们似乎仍然挺过来了。可能是什么原因?

 <httpModules>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="SecuritySwitch" type="SecuritySwitch.SecuritySwitchModule, SecuritySwitch" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>

<errorFilter>
<test>
<regex binding="Exception.Message" pattern="(?ix: \b This \b.+?\b is \b.+?\b an \b.+?\b invalid \b.+?\b webresource \b.+?\b request \b )" />
</test>
<test>
<regex binding="Exception.Message" pattern="(?ix: \b Path \b.+?\b eurl.axd \b )" />
</test>
<test>
<regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" />
</test>
</errorFilter>

最佳答案

我相信你只能有单个测试元素。关键是从 <or></or> 开始元素并将过滤器嵌套在其中。这当然对我们有用。

<errorFilter>
<test>
<or>
<!-- Don't email 404 errors -->
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
<!-- Don't log cancelled downloads -->
<and>
<equal binding="HttpStatusCode" value="500" type="Int32" />
<equal binding="Context.Request.ServerVariables['URL']" value="/Download.aspx" type="String" />
<or>
<regex binding="BaseException.Message" pattern="0x80070016" caseSensitive="false" />
<regex binding="BaseException.Message" pattern="0x800704CD" caseSensitive="false" />
</or>
</and>
<!--Viewstate Corruption-->
<or>
<regex binding="Exception" type="System.Web.HttpException" pattern="System.FormatException: Invalid length for a Base-64 char array." caseSensitive="false" />
<regex binding="Exception" type="System.Web.HttpException" pattern="System.FormatException: Invalid character in a Base-64 string." caseSensitive="false" />
</or>
<!-- IE8 Bug -->
<and>
<regex binding="Context.Request.ServerVariables['HTTP_USER_AGENT']" pattern="Trident\/4\.0" />
<or>
<equal binding="Context.Request.ServerVariables['URL']" value="/ScriptResource.axd" type="String" />
<equal binding="Context.Request.ServerVariables['URL']" value="/WebResource.axd" type="String" />
</or>
</and>
</or>
</test>
</errorFilter>

更多信息请参见:

http://www.diaryofaninja.com/blog/2011/09/20/adding-filters-to-your-elmah-installation

关于Elmah 错误过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10127302/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com