我不能让我的ELMAH电子邮件过滤器工作 [英] I can't get my Elmah email filters to work

查看:124
本文介绍了我不能让我的ELMAH电子邮件过滤器工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的web.config设置和ELMAH查询。问题是,这我仍然获得电子邮件有关的公共操作方法的问题时,我不想。似乎不是我的地方的过滤器将是工作。

我不能完全肯定的AND和OR怎样都应该在ELMAH邮件过滤工作,特别是因为这code是从一些我从其他开发商采取板载项目工作剪断。

该标签是为了prevent经由电子邮件被报道含有任何的字索引,缓存或登录。

任何错误

谁能帮助?

 <结构>
    < configSections>
        <! -  ELMAH sectionGroup  - >
        < sectionGroup名=ELMAH>
            <节名称=安全requirePermission =假TYPE =Elmah.SecuritySectionHandler,ELMAH/>
            <节名称=错误日志requirePermission =假TYPE =Elmah.ErrorLogSectionHandler,ELMAH/>
            <节名称=errorMailrequirePermission =假TYPE =Elmah.ErrorMailSectionHandler,ELMAH/>
            <节名称=errorFilterrequirePermission =假TYPE =Elmah.ErrorFilterSectionHandler,ELMAH/>
        < / sectionGroup>
  < / configSections>

 < ELMAH>
<错误日志型=Elmah.XmlFileErrorLog,ELMAH日志路径=〜/ App_Data文件/>
< errorMail来自=为=主题=错误(ELMAH)异步=真/>
    &所述;安全allowRemoteAccess =1/>
< errorFilter>
  <试验>
    &所述或GT;
        <为-类型绑定=BaseExceptionTYPE =System.InvalidOperationException/>
&所述; /或GT;
&所述或GT;
    <正则表达式绑定=Exception.Message模式=(九:\ b可能\ B + \ b危险\ B + \ B值\ B + \ b检测\ B + \?。?。?。?。? B客户端\ B)/>
&所述; /或GT;
&所述或GT;
    <正则表达式绑定=Exception.Message模式=(九:\ b公益行动方法索引是不是在控制器\ b找到)/>
    <正则表达式结合=Exception.Message模式=(九:\ b公共行为法缓存是不是在控制器\ b发现了什么?)/>
    <正则表达式结合=Exception.Message模式=(九:\ b公共行为法登陆并没有在控制器\ b发现了什么?)/>
&所述; /或GT;
  < /试验>
< / errorFilter>
  < / ELMAH>
  <位置路径=elmah.axd>
  < /地点>
  <的System.Web>
  < /system.web>
 < system.webServer>
<模块runAllManagedModulesForAllRequests =真正的>
<添加名称=错误日志TYPE =Elmah.ErrorLogModule,ELMAH/>
<添加名称=ErrorMailTYPE =Elmah.ErrorMailModule,ELMAH/>
<添加名称=ErrorFilterTYPE =Elmah.ErrorFilterModule,ELMAH/>
< /模块>
<处理>
  <添加名称=HttpHandler的动词=POST,GET,HEAD路径=elmah.axdTYPE =Elmah.ErrorLogPageFactory,ELMAH/>
   < /处理器>
  < /system.webServer>
< /结构>
 

解决方案

测试元素只能有一个孩子断言所以有多个在它下面的元素意味着所有,但第一个被忽略。从你的描述,看来你的测试元素,而不是这样写的:

 <试验>
  &所述或GT;
    <为-类型绑定=BaseExceptionTYPE =System.InvalidOperationException/>
    <正则表达式绑定=Exception.Message模式=(九:\ b可能\ B + \ b危险\ B + \ B值\ B + \ b检测\ B + \?。?。?。?。? B客户端\ B)/>
    &其中;和>
      <正则表达式结合=FilterSourceType.Name模式=邮件/>
      <正则表达式绑定=Exception.Message模式=(九:\ b公共\ S动作\ S法\ S'(索引|缓存|登录)\ S为\不是\ S发现\ S上\? S控制器\ B)/>
    < /和大于
  &所述; /或GT;
< /试验>
 

请注意,我也说干就干,折叠三个正则表达式元素融入其中,并正确地固定分隔单词模式(\ <$ C C $> B 上边缘和 \ S 插图中)。

I have a query about the following web.config setup and Elmah. The problem is that it I still get emails regarding the public action method issues when I don't want to. The filters I have in place don't seem to be working.

I am not entirely sure how the ANDs and ORs are supposed to work in Elmah email filtering, especially as this code is snipped from some project work I have taken onboard from other developers.

The tags are meant to prevent any errors from being reported via email that contain any of the words Index, cache or Login.

Can anyone help?

<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>

解决方案

The test element can only have one child assertion so having multiple or elements underneath it means all but the first are being ignored. From your description, it seems your test element should instead read like this:

<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>

Note that I also went ahead and folded the three regex elements into one and fixed the pattern to delimit words correctly (\b on edges and \s inbetween).

这篇关于我不能让我的ELMAH电子邮件过滤器工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆