示例#1
0
        // [OutputCache(CacheProfile = CacheProfileName.Error)]
        public ActionResult Error(int statusCode, string status)
        {
            var error = Context.GetFeature<IErrorHandlerFeature>();

            this.Response.StatusCode = statusCode;
            var model = new ErrorPageModel();
            if (error != null)
            {
                model = new ErrorPageModel
                {
                    ErrorDetails = GetErrorDetails(error.Error, false),
                    Headers = Request.Headers,
                    Query = Request.Query,
                };
            }
            ActionResult result;
            if (this.Request.IsAjaxRequest())
            {
                // This allows us to show errors even in partial views.
                result = this.PartialView(statusCode.ToString(), model);
            }
            else
            {
                result = this.View(statusCode.ToString(), model);
            }

            return result;
        }
        // Assumes the response headers have not been sent.  If they have, still attempt to write to the body.
        private void DisplayException(HttpContext context, Exception ex)
        {
            var request = context.Request;

            ErrorPageModel model = new ErrorPageModel()
            {
                Options = _options,
            };

            if (_options.ShowExceptionDetails)
            {
                model.ErrorDetails = GetErrorDetails(ex, _options.ShowSourceCode).Reverse();
            }
            if (_options.ShowQuery)
            {
                model.Query = request.Query;
            }/* TODO:
            if (_options.ShowCookies)
            {
                model.Cookies = request.Cookies;
            }*/
            if (_options.ShowHeaders)
            {
                model.Headers = request.Headers;
            }/* TODO:
            if (_options.ShowEnvironment)
            {
                model.Environment = context;
            }*/

            var errorPage = new ErrorPage() { Model = model };
            errorPage.Execute(context);
        }
        private Task DisplayRuntimeException(HttpContext context, Exception ex)
        {
            var request = context.Request;

            var model = new ErrorPageModel
            {
                Options = _options,
                ErrorDetails = GetErrorDetails(ex).Reverse(),
                Query = request.Query,
                Cookies = request.Cookies,
                Headers = request.Headers
            };

            var errorPage = new ErrorPage(model);
            return errorPage.ExecuteAsync(context);
        }
示例#4
0
 public ErrorPage(ErrorPageModel model)
 {
     Model = model;
 }
示例#5
0
 public ErrorPage(ErrorPageModel model)
 {
     Model = model;
 }