asp.net – ELMAH日志如何按类型忽略错误

你好,我在我的项目中设置了ELMAH,但是我遇到了很多错误

System.Web.HttpException: A potentially dangerous Request.Path value
was detected from the client (:).

Generated: Sun,26 May 2013 21:46:30 GMT

System.Web.HttpException (0x80004005): A potentially dangerous
Request.Path value was detected from the client (:). at
System.Web.HttpRequest.ValidateInputIfrequiredByConfig() at
System.Web.HttpApplication.PipelinestepManager.ValidateHelper(HttpContext
context)

我想忽略它们,不要发送到我的邮件,但写入ELMAH DB.
有可能吗?

解决方法

是的,您可以使用ELMAH中的 error filtering,哪个是 described in detail on the project wiki.总之,web.config中的以下过滤器应该执行此操作(假设您已经设置了模块配置部分):
<errorFilter>
    <test>
        <and>
            <regex binding="FilterSourceType.Name" pattern="mail" />
            <regex binding="Exception.Message" 
               pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" />
        </and>
    </test>
</errorFilter>

一个<正则表达式>条件filters based on the filtering source,使邮寄不会发生. Check out the documentation on the wiki for full details.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....