相关疑难解决方法(0)

ELMAH - 过滤404错误

我正在尝试配置ELMAH来过滤404错误,我在Web.config文件中遇到了XML提供的过滤规则.我按照这里这里的教程,<is-type binding="BaseException" type="System.IO.FileNotFoundException" />在我的<test><or>...声明中添加了一个声明,但完全失败了.

当我在本地测试它时,我void ErrorLog_Filtering() {}在Global.asax中插入了一个断点,并发现System.Web.HttpExceptionASP.NET为404 启动的那个似乎没有基本类型System.IO.FileNotFound,而是它只是一个System.Web.HttpException.我通过调用e.Exception.GetBaseException().GetType()事件处理程序来测试它.

接下来我决定尝试一个<regex binding="BaseException.Message" pattern="The file '/[^']+' does not exist" />希望任何匹配模式"文件'/ foo.ext'不存在"的异常消息将被过滤,但这也没有效果.作为最后的手段我尝试过<is-type binding="BaseException" type="System.Exception" />,甚至完全无视.

我倾向于认为ELMAH存在配置错误,但我没有看到任何错误.我错过了一些明显的东西吗?

这是我的web.config中的相关内容:

<configuration>
  <configSections>
    <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>
    <errorFilter>
      <test>
        <or>
          <equal binding="HttpStatusCode" value="404" type="Int32" …
Run Code Online (Sandbox Code Playgroud)

asp.net filtering elmah

23
推荐指数
1
解决办法
9885
查看次数

标签 统计

asp.net ×1

elmah ×1

filtering ×1