Esempio n. 1
0
 protected override void Execute(RequestContext requestContext)
 {
     // This is handling the case when the routing cannot match a controller, or when
     // the routing may identify an actual file (eg. *.cshtml). The later only seems
     // to end up here though if AtlasExceptionHttpModule is used.
     AtlasExceptionAction.ExecutePageNotFound(requestContext, null);
 }
Esempio n. 2
0
        public bool EndInvokeAction(IAsyncResult asyncResult)
        {
            bool result;

            try
            {
                result = this.actionInvoker.EndInvokeAction(asyncResult);
            }
            catch (InvalidOperationException e)
            {
                if (e.Message != "No route in the route table matches the supplied values.")
                {
                    throw;
                }

                result = false;
            }

            if (!result)
            {
                // This is handling the case when the routing matches a controller, but not an action
                AtlasExceptionAction.ExecutePageNotFound((ControllerContext)asyncResult.AsyncState, null);
            }

            return(true);
        }
Esempio n. 3
0
        public void OnException(ExceptionContext filterContext)
        {
            if (filterContext == null)
            {
                throw new ArgumentNullException("filterContext");
            }

            if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled)
            {
                return;
            }

            HttpStatusCode statusCode;
            string         viewName;

            var isAjax        = filterContext.HttpContext.Request.IsAjaxRequest();
            var httpException = filterContext.Exception as HttpException;

            if (httpException != null && httpException.GetHttpCode() == (int)HttpStatusCode.NotFound)
            {
                statusCode = HttpStatusCode.NotFound;
                viewName   = isAjax  ? this.AjaxPageNotFoundView : this.PageNotFoundView;
            }
            else
            {
                statusCode = HttpStatusCode.InternalServerError;
                viewName   = isAjax ? this.AjaxUnexpectedErrorView : this.UnexpectedErrorView;
            }

            filterContext.Result           = AtlasExceptionAction.ViewResultResponse(filterContext.HttpContext, statusCode, viewName, filterContext.Exception);
            filterContext.ExceptionHandled = true;
        }
Esempio n. 4
0
        public bool InvokeAction(ControllerContext controllerContext, string actionName)
        {
            var result = this.actionInvoker.InvokeAction(controllerContext, actionName);

            if (!result)
            {
                // This is handling the case when the routing matches a controller, but not an action
                AtlasExceptionAction.ExecutePageNotFound(controllerContext, null);
            }

            return(true);
        }
Esempio n. 5
0
        private void HttpApplicationError(object sender, EventArgs e)
        {
            var httpApplication = (HttpApplication)sender;
            var context         = httpApplication.Context;
            var exception       = context.Server.GetLastError();

            var httpException = exception as HttpException;

            if (httpException != null && httpException.GetHttpCode() == (int)HttpStatusCode.NotFound)
            {
                context.Server.ClearError();

                AtlasExceptionAction.ExecutePageNotFound(context.Request.RequestContext, httpException);
            }
        }