Esempio n. 1
0
        public ActionResult Index(ErrorViewModel model)
        {
            var seo = this.GetSeoHelper();
            seo.MetaNoIndex = true;

            return this.View("Error", model);
        }
        public override void Handle(ExceptionHandlerContext context)
        {
            bool shouldHandle = this.ShouldHandle(context);
            if (!shouldHandle)
            {
                return;
            }

            ErrorContext errorContext = null;

            try
            {
                errorContext = ErrorContextService.Resolve(context);

                var model = new ErrorViewModel(errorContext, context.RequestContext.RouteData.Values);
                var jsonModel = model.ToJson();

                var response = context.Request.CreateResponse(errorContext.HttpStatusCode, jsonModel);

                context.Result = new ResponseMessageResult(response);
            }
            finally
            {
                ErrorContextService.Log(CurrentLogger, errorContext);
            }
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            var exception = this.Server.GetLastError();

            var context = ErrorContextService.Resolve(exception, this.User);
            var model = new ErrorViewModel(context, this.RouteData.Values);

            return this.Index(model);
        }
        private static ActionResult GetDefaultErrorResult(ErrorContext errorContext, HttpContextBase httpContext)
        {
            var model = new ErrorViewModel(errorContext, httpContext.Request.RequestContext.RouteData.Values);

            var tempData = (httpContext.Session != null)
                               ? httpContext.Session[TempDataSessionStateKey] as TempDataDictionary
                               : null;

            return new ViewResult
                       {
                           ViewName = "~/Views/Shared/Error.cshtml",
                           MasterName = string.Empty,
                           ViewData = new ViewDataDictionary<ErrorViewModel>(model),
                           TempData = tempData ?? new TempDataDictionary()
                       };
        }