1

I have implemented ELMAH with help of this post (@Ivan Zlatev answer). It is working fine. But now I need to redirect default error page with error message.

How can I do this?. I was reading with ELMAH, we can not implement custom error page. Is it true?

 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);
    }
}
Community
  • 1
  • 1
James123
  • 11,184
  • 66
  • 189
  • 343

1 Answers1

3

Elmah is for logging errors, Creating custom error page is a different step. You can do it using your 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> 

And then you will have to implement the error.aspx 400.aspx 500.aspx pages.

MoXplod
  • 3,813
  • 6
  • 36
  • 46