public override object Execute(ControllerContext controllerContext, IDictionary <string, object> parameters) { if (controllerContext == null) { throw new ArgumentNullException(nameof(controllerContext)); } int statusCode = 404; if (this.descriptor != null) { try { return(this.descriptor.Execute(controllerContext, parameters)); } catch (HttpException ex) { if (GlobalErrorConfig.CustomData.StatusCodes.IndexOf(ex.GetHttpCode()) > -1) { statusCode = ex.GetHttpCode(); } else { throw; } } } IGlobalErrorController errorController = GlobalErrorHandler.CreateErrorController(controllerContext.RequestContext); controllerContext.RouteData.Values["action"] = GlobalErrorConfig.CustomData.ErrorActionName; return(errorController.GlobalError(statusCode)); }
private static void ExecuteNotFoundControllerAction(ControllerContext controllerContext) { IController controller; if (GlobalErrorHandler.CreateErrorController != null) { controller = GlobalErrorHandler.CreateErrorController(controllerContext.RequestContext) ?? new GlobalErrorController(); } else { controller = new GlobalErrorController(); } controller.Execute(controllerContext.RequestContext); }
public IController CreateController(RequestContext requestContext, string controllerName) { try { var controller = this.factory.CreateController(requestContext, controllerName); WrapControllerActionInvoker(controller); return(controller); } catch (HttpException ex) { if (GlobalErrorConfig.CustomData.StatusCodes.IndexOf(ex.GetHttpCode()) > -1) { return(GlobalErrorHandler.CreateErrorController(requestContext)); } throw; } }