Custom Error Pages with ASP.NET MVC 5 and Elmah

asp.net-mvc-5, elmah

Solution

You can do the following from ELMAH.MVC 2.0.2 is out:

Set `disableHandleErrorFilter` to `true`:

<add key="elmah.mvc.disableHandleErrorFilter" value="true" />

Remove `filters.Add(new HandleErrorAttribute());` from `FilterConfig` class:

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
      // filters.Add(new HandleErrorAttribute()); // <-- comment out
    }
}

Problem

I am trying make work custom error page in asp mvc 5 but for some strange reason at moment to test my page, from elmah i am loging two errors ( the real error what i am testing and a error related with error page not found: The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/HotTowel/Error.aspx ~/Views/HotTowel/Error.ascx ~/Views/Shared/Error.aspx ~/Views/Shared/Error.ascx ~/Views/HotTowel/Error.cshtml ~/Views/HotTowel/Error.vbhtml ~/Views/Shared/Error.cshtml ~/Views/Shared/Error.vbhtml I was looking into this url http://doingthedishes.com/2011/09/10/custom-errors-mvc-3-elmah.html, where the author had the same issue but with asp.net mvc 3. After read it, I tried remove the call to HandleErrorAttribute: ``` public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { //filters.Add(new HandleErrorAttribute()); } } ``` But the issue is still there: i can see my custom page but asp.net mvc is throwing two exceptions. Any help? the solution is rewrite a class derived from HandleErrorAttribute ? like this post: keep getting The view "Error" not found when using Elmah and asp.net mvc 4 ?

Original source