asp.net mvc - MVC - filterContext.ExceptionHandled -


Is filterContext.ExceptionHandled property always set to true by MVC or is it set to true by user code only? If that's the case then why does this happen?

filterContext.ExceptionHandled is set to true when an exception is by an action method By default HandleErrorAttribute has been added to the FilterConfig class which is registered in Application_Start () . When an exception occurs, the OnException method is called in the HandleErrorAttribute class. OnException method in

, response before removing existing one. The HTTP response body, ExceptionHandled will be set to correct using the Clear () property.

Below is the default built-in method:

  Public Virtual Zero OnxSation (Exception Consultant Filter Contracts) {if (filterContext == null) {New Logic (NullException) ("Filter Contex "); } If (filterContext.IsChildAction) {return; } If (filterContext.ExceptionHandled ||! FilterContact ..httptex.ISISISISIISISERERAnited) {Return; } Exception exception = filterContext.Exception; If (new HTTP Exception (empty, exception) .GetHttpCode ()! = 500) {Return; } If (ExceptionType.IsInstanceOfType (exception)) {return; } String control name = (string) filterContext.RouteData.Values ​​["controller"]; String action name = (string) filterContext.RouteData.Values ​​["action"]; HandleErrorInfo Model = New HandleErrorInfo (filterContext.Exception, ControlName, Action Name); FilterContext.Result = New ViewResult {ViewName = View, MasterName = Master, View Data = New ViewDataDictionary & lt; HandleErrorInfo & gt; (Model), TempData = filterContext.Controller.TempData}; FilterContext.ExceptionHandled = True; FilterContext.HttpContext.Response.Clear (); FilterContext.HttpContext.Response.StatusCode = 500; FilterContext.HttpContext.Response.TrySkipIisCustomErrors = True; }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -