Redirect from the OnException-method inside the controller with ASP.Net MVC

Posted by Eric Bartels

If your controller uses the HandleError-Attribute it handles exceptions thrown by action methods. I wanted to catch these exceptions and redirect to a custom error page. A simple RedirectToAction inside the OnException method does not work. But the ExceptionContext is all we need. #region Error handling protected override void OnException(ExceptionContext filterContext) { // Make use [...]