2014-06-09 53 views
1

我在post(@Ivan Zlatev答案)的幫助下實施了ELMAH。它工作正常。但是現在我需要用錯誤信息重定向默認錯誤頁面。ELMAH實施後如何重定向到默認錯誤頁面?

我該怎麼做?我正在閱讀ELMAH,我們無法實現自定義錯誤頁面。這是真的嗎?

public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
{ 
    filters.Add(new ElmahHandledErrorLoggerFilter()); 
    filters.Add(new HandleErrorAttribute()); 
} 

public class ElmahHandledErrorLoggerFilter : IExceptionFilter 
{ 
    public void OnException(ExceptionContext context) 
    { 
     // Log only handled exceptions, because all other will be caught by ELMAH anyway. 
     if (context.ExceptionHandled) 
      ErrorSignal.FromCurrentContext().Raise(context.Exception); 
    } 
} 

回答

3

Elmah用於記錄錯誤,創建自定義錯誤頁面是一個不同的步驟。你可以使用它你的web.config

<configuration> 
<system.web> 
    <customErrors mode="On" defaultRedirect="error.aspx"> 
     <error statusCode="404" redirect="404.aspx" /> 
     <error statusCode="500" redirect="500.aspx" /> 
    </customErrors> 
</system.web> 
</configuration> 

,然後你將不得不實現error.aspx 400.aspx 500.aspx做網頁。

相關問題