Example #1
0
        public bool InvokeAction(ControllerContext controllerContext, string actionName)
        {
            if (InvokeActionWithNotFoundCatch(controllerContext, actionName))
            {
                return(true);
            }

            controllerContext.RequestContext.RouteData.Values["action"] = "NotFound";
            IController controller = new HttpErrorsController();

            controller.Execute(controllerContext.RequestContext);

            return(true);
        }
Example #2
0
        protected void Application_Error()
        {
            var exception     = Server.GetLastError();
            var httpException = exception as HttpException;

            Response.Clear();
            Server.ClearError();

            var routeData = new RouteData();

            routeData.Values["controller"] = "HttpErrors";
            routeData.Values["action"]     = "General";
            routeData.Values["exception"]  = exception;
            Response.StatusCode            = 500;
            if (httpException != null)
            {
                Response.StatusCode = httpException.GetHttpCode();
                switch (Response.StatusCode)
                {
                case 404:
                    routeData.Values["action"] = "Http404";
                    break;

                default:
                    routeData.Values["action"] = "ApplicationError";
                    break;
                }
            }
            else
            {
                routeData.Values["action"] = "ApplicationError";
            }

            if (httpException == null)
            {
                routeData.Values["action"] = "ApplicationError";
                EmailHelper.SendErrorEMail(exception, System.Web.HttpContext.Current.Session["userId"] != null ? System.Web.HttpContext.Current.Session["w_user"].ToString() : string.Empty);
            }

            // Avoid IIS7 getting in the middle
            Response.TrySkipIisCustomErrors = true;
            IController        errorsController = new HttpErrorsController();
            HttpContextWrapper wrapper          = new HttpContextWrapper(Context);
            var rc = new RequestContext(wrapper, routeData);

            errorsController.Execute(rc);
        }