My controller is decorated with [HandleError]
and [HandleError(ExceptionType=typeof(CustomException), View="CustomView")]
. I have views that consist of multiple partial views from multiple controllers, so we're displaying our partial views using <% RenderAction(...) %>
but now we have a case where our action being rendered is throwing a CustomException. I overrode OnException
inside HandleErrorAttribute
which gets called (twice for some reason) with the CustomException
, and then two more times with System.Web.HttpUnhandledException
, before being redirected to the default Error.aspx
page instead of to CustomView
where it should go with this error.
Also, if I remove [HandleError]
but keep [HandleError(ExceptionType=typeof(CustomException), View="CustomView")]
the HandleErrorAttribute.OnException
override never fires.
How do I throw CustomException types from an action that renders a partial view, and still have the app redirect to my CustomView?