Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我能';我的Elmah邮件过滤器无法正常工作_C#_.net_Elmah - Fatal编程技术网

C# 我能';我的Elmah邮件过滤器无法正常工作

C# 我能';我的Elmah邮件过滤器无法正常工作,c#,.net,elmah,C#,.net,Elmah,我有一个关于以下web.config设置和Elmah的问题。问题是,当我不想的时候,我仍然会收到关于公共行动方法问题的电子邮件。我安装的过滤器似乎不起作用 我不完全确定ANDs和ORs在Elmah电子邮件过滤中应该如何工作,特别是因为这段代码是从我从其他开发人员那里获得的一些项目工作中截取的 这些标签旨在防止任何错误通过包含索引、缓存或登录的电子邮件报告 有人能帮忙吗 <configuration> <configSections> <!--

我有一个关于以下web.config设置和Elmah的问题。问题是,当我不想的时候,我仍然会收到关于公共行动方法问题的电子邮件。我安装的过滤器似乎不起作用

我不完全确定ANDs和ORs在Elmah电子邮件过滤中应该如何工作,特别是因为这段代码是从我从其他开发人员那里获得的一些项目工作中截取的

这些标签旨在防止任何错误通过包含索引、缓存或登录的电子邮件报告

有人能帮忙吗

<configuration>
    <configSections>
        <!--Elmah sectionGroup-->
        <sectionGroup name="elmah">
            <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
            <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
            <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
            <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
        </sectionGroup>
  </configSections>  

 <elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
<errorMail from="" to="" subject="Error(Elmah)" async="true " />
    <security allowRemoteAccess="1"/>
<errorFilter>
  <test>
    <or>
        <is-type binding="BaseException" type="System.InvalidOperationException" />
</or>
<or>
    <regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" />
</or>
<or>
    <regex binding="Exception.Message" pattern="(?ix: \b public action method     'Index' was not found on controller \b )" />
    <regex binding="Exception.Message" pattern="(?ix: \b public action method 'cache' was not found on controller \b )" />
    <regex binding="Exception.Message" pattern="(?ix: \b public action method 'Login' was not found on controller \b )" />
</or>
  </test>
</errorFilter>
  </elmah>  
  <location path="elmah.axd">
  </location>  
  <system.web>
  </system.web>
 <system.webServer>    
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</modules>
<handlers>
  <add name="httpHandler" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
   </handlers>
  </system.webServer>
</configuration>

test元素只能有一个子断言,因此在它下面有多个
元素意味着除第一个元素外的所有元素都被忽略。根据您的描述,您的
测试
元素应该改为如下:

<test>
  <or> 
    <is-type binding="BaseException" type="System.InvalidOperationException" /> 
    <regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" /> 
    <and> 
      <regex binding="FilterSourceType.Name" pattern="mail" />
      <regex binding="Exception.Message" pattern="(?ix: \b public \s action \s method \s '(Index|cache|Login)' \s was \s not \s found \s on \s controller \b )" /> 
    </and>
  </or> 
</test>


请注意,我还将三个
regex
元素折叠成一个,并固定了模式以正确地分隔单词(
\b
在边缘和
\s
中间).

test
元素只能有一个子断言,因此在它下面有多个
元素意味着除第一个元素外,所有元素都被忽略。根据您的描述,您的
测试
元素应该改为如下:

<test>
  <or> 
    <is-type binding="BaseException" type="System.InvalidOperationException" /> 
    <regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" /> 
    <and> 
      <regex binding="FilterSourceType.Name" pattern="mail" />
      <regex binding="Exception.Message" pattern="(?ix: \b public \s action \s method \s '(Index|cache|Login)' \s was \s not \s found \s on \s controller \b )" /> 
    </and>
  </or> 
</test>

请注意,我还将三个
regex
元素折叠成一个,并修复了模式以正确地分隔单词(
\b
在边缘和
\s
中间)