Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RedirectOnErrorAttribute : FilterAttribute, IExceptionFilter {
- #region IExceptionFilter Members
- public void OnException(ExceptionContext filterContext) {
- if(filterContext.ExceptionHandled) return;
- filterContext.Controller.TempData["Exception"] = filterContext.Exception;
- filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new {area = "Desktop", controller = "Exception", action = "HandleError" }));
- filterContext.ExceptionHandled = true;
- filterContext.HttpContext.Response.Clear();
- filterContext.HttpContext.Response.StatusCode = 500;
- filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
- }
- #endregion
- }
- public ActionResult HandleError() {
- Exception ex = (Exception)TempData["Exception"];
- logger.Log(ex);
- }
Add Comment
Please, Sign In to add comment