Basically when my app has an unhandled exception I want it to be recorded as an unhandled exception by IIS (so that it can be seen on Event Viewer, for example) but I also want to route the user to an error controller.
I've overridden the OnException
method of my controller in order to route users to a custom error page. The crux of the problem is this code:
protected override void OnException(ExceptionContext filterContext)
{
filterContext.Result = RedirectToAction("GeneralError", "Error", new{ routeValueA = "some value", routeValueB = "some other value"});
filterContext.ExceptionHandled = false;
}
My Problem is this: If I set filterContext.ExceptionHandled = false
then I get a yellow screen of death instead of being rerouted to my error handling controller. If i set filterContext.ExceptionHandled = true
then I get rerouted, but the exception is not recorded as an unhandled exception.
I know I can set a static error page using the web.config, but I don't want to do this, because then I can't use route values to dynamically send data to my Error Controller.
Can I succesfully set a result to my filterContext.Result
without marking filterContext.ExceptionHandled= true
?