In the customErrors tag in my web.config, I am pointing to a controller. In my controller I am redirecting to an external error page that is shared by multiple applications.
<customErrors defaultRedirect="~/Error/ServerError" mode="On">
My controller:
public class ErrorController : Controller
{
public ActionResult ServerError()
{
return Redirect("/Systems/ASPNETErrorHandling/ErrorPage.aspx");
}
public ActionResult ErrorTest()
{
throw new Exception("testing error handling");
}
}
I'm calling Error/ErrorTest to test the error handling. But it always redirects to Views/Shared/Error.cshtml instead of redirecting to the controller I specified.
How do I get asp.net mvc to honor the defaultRedirect path in my customErrors settings?
UDPATE: I'm also using ELMAH and overriding the HandleErrorAttribute as described in this post. I see from .Net Reflector that the base HandleErrorAttribute is setting Error as the view. I don't think there's much I can do about it redirecting to Error.cshtml, or some other view.