不涉及正则表达式的解决方案,只需添加到您的Global.asax.cs:
protected void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
if (e.Message == "A potentially dangerous Request.Path value was detected from the client (:).")
e.Dismiss();
}
// this method may also be useful
protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
if (e.Message == "A potentially dangerous Request.Path value was detected from the client (:).")
{
// do something
}
}
或者你也可以使用这两种方法:
void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs args)
{
Filter(args);
}
void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs args)
{
Filter(args);
}
void Filter(ExceptionFilterEventArgs args)
{
if (args.Exception.GetBaseException() is HttpRequestValidationException)
args.Dismiss();
}
我不能让它停止发送“System.InvalidOperationException:请求的资源只能通过SSL访问。”我的模式是: <等于结合= “HttpStatusCode” 值= “404” 型= “的Int32”/> <正则表达式结合= “FilterSourceType.Name” 图案= “邮件”/> –
@Rysystephens你应该有一个''节点,所以第二个被忽略。您需要将''与您的404&消息模式案例一起,然后''与邮件源案例一起使用。您为什么不在SO或ELMAH讨论组(http://groups.google.com/group/elmah)上发布这个问题作为另一个问题,我们可以从那里拿走它? –