簡體   English   中英

asp.net mvc 2 customErrors iis 7.5無效

[英]asp.net mvc 2 customErrors iis 7.5 not working

我的網站在asp.net mvc2上運行,我正在使用elmah進行錯誤捕獲,而不是處理錯誤的錯誤

如果我瀏覽到非現有頁面,如'http:// localhost:8095 / Home / City / 1 / mtl / ko',我會收到IIS錯誤404頁面

在web.config中我配置了自定義錯誤

我甚至試圖在global.asax application_error中設置代碼,但它並沒有被困在那里

為什么我收到IIS 404錯誤頁面?

現在我考慮一下,我想記錄404錯誤,我會在asp.net mvc中捕獲這些錯誤?

謝謝

我知道這是一個老問題,但我想我回答:

Elmah具有您可以應用的過濾功能: http//code.google.com/p/elmah/wiki/ErrorFiltering

啟用錯誤過濾后,您需要修改Gloabal.asax.cs以過濾錯誤:

public static void RegisterRoutes(RouteCollection routes)
{               
    routes.IgnoreRoute("elmah.axd"); //Add this line to the register routes.
}

//ELMAH Filtering
protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
    FilterError404(e);
}

protected void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
    FilterError404(e);
}

//Dimiss 404 errors for ELMAH
private void FilterError404(ExceptionFilterEventArgs e)
{
    if (e.Exception.GetBaseException() is HttpException)
    {
        HttpException ex = (HttpException)e.Exception.GetBaseException();

        if (ex.GetHttpCode() == 404)
        {
            e.Dismiss();
        }
    }
}

但坦率地說,我喜歡記錄包括404錯誤在內的所有內容。 這使我可以更好地了解用戶如何進入或發現新功能以便在需要時提供支持。

其他資源: http//joel.net/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering http://ivanz.com/2011/05/08/ ASP凈MVC-神奇-錯誤記錄與- ELMAH /

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM