Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- how could i catch the MVC3 exception and not return an blank view?
- protected override void OnException(ExceptionContext filterContext)
- {
- base.OnException(filterContext);
- var exception = new HttpException(null, filterContext.Exception);
- if (exception.GetHttpCode() == (int)HttpStatusCode.InternalServerError)
- {
- if (WebConstants.systemHandleExceptionList.Contains(filterContext.Exception.GetType()))
- {
- //process the error
- SaveErrorMessage(filterContext.Exception.GetType().Name);
- filterContext.ExceptionHandled = true;
- }
- else
- {
- //record the unhandle message to log
- errorlog.Error("", filterContext.Exception);
- }
- }
- }
- RouteValueDictionary errorRouteValues = new RouteValueDictionary( new { controller = "Error", action = "Action" } );
- filterContext.Result = new ActionRedirectResult( errorRouteValues );
- filterContext.Cancel = true;
Add Comment
Please, Sign In to add comment