不涉及正則表達式的解決方案,只需添加到您的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)上發佈這個問題作爲另一個問題,我們可以從那裏拿走它? –