我有一个自定义异常过滤器属性:
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
}
'ExceptionController'的Action'HandleError'包含一些业务逻辑 在'HandleError'动作中
public ActionResult HandleError() {
Exception ex = (Exception)TempData["Exception"];
logger.Log(ex);
}
在ex变量中,我总是得到异常消息'错误执行处理程序的子请求'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'。'
如何解决我的问题?
答案 0 :(得分:0)
您可以尝试查看ex.InnerException
。如果它不为null,则可能包含更多有用的信息。