2014-06-09 52 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做网页。

相关问题