I have an ASP.NET MVC 3 application configured to redirect to an Errors controller with two actions -
<customErrors mode="On" defaultRedirect="/Errors/ApplicationError"> <error statusCode="404" redirect="/Errors/NotFound" /> </customErrors>
I have a couple of views that are displayed from each of the action methods:
/Views/Shared/NotFound.cshtml/Views/Shared/ApplicationError.cshtml
In my ErrorsController ApplicationError action, I do the following:
public ActionResult ApplicationError() { Response.StatusCode = 500; return View(); }
This works, and my view of ApplicationError.cshtml rendered, no matter what happened, anything happened.
However, in ELMAH I see this additional error:
System.InvalidOperationException The Error view or its wizard was not found, or the view mechanism does not support the locations found. The following locations were searched: ~ / Views / Throw / Error.aspx ~ / Views / Throw / Error.ascx ~ / Views / Shared / Error.aspx ~ / Views / Shared / Error.ascx ~ / Views / Throw / Error. cshtml ~ / Views / Throw / Error.vbhtml ~ / Views / Shared / Error.cshtml ~ / Views / Shared / Error.vbhtml
Why is ASP.NET MVC still looking for these views when I have already handled the error and my own view is successfully positioned and displayed?
Additional Information:
I do not use the [HandleError] attribute anywhere
I replaced filters.Add(new HandleErrorAttribute()); on Global.asax.cs on filters.Add(new ElmahHandleErrorAttribute()); according to this tip , which is based on this answer to the stack overflow from Atif by ELMAH .
source share