你好,我在我的项目中设置了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.