系统未知bug,代码没有深究。 现象:filters.Add(new HandleErrorAttribute()); 使用了全局的异常处理过滤。HandleErrorAttribute 核心代码:public virtual void OnException(Excepti ...
系统未知bug,代码没有深究。
现象:filters.Add(new HandleErrorAttribute()); 使用了全局的异常处理过滤。
HandleErrorAttribute 核心代码:
public virtual void OnException(ExceptionContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext"); } if (filterContext.IsChildAction) { return; } if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) { return; } Exception exception = filterContext.Exception; if (new HttpException(null, exception).GetHttpCode() != 500) { return; } if (!this.ExceptionType.IsInstanceOfType(exception)) { return; } get='_blank'>string controllerName = (string)filterContext.RouteData.Values["controller"]; string actionName = (string)filterContext.RouteData.Values["action"]; HandleErrorInfo model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName); filterContext.Result = new ViewResult { ViewName = this.View, MasterName = this.Master, ViewData = new ViewDataDictionary<HandleErrorInfo>(model), TempData = filterContext.Controller.TempData }; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 500; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:asp.net mvc HandleErrorAttribute 异常错误处理 无效!
关键词:ASP.NET
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。