Exemple #1
0
        public ActionResult Error()
        {
            string _errorID     = Request.QueryString["ErrorID"];
            string _errorNumber = Request.QueryString["ErrorNumber"];

            if (!string.IsNullOrEmpty(_errorID))
            {
                var _error = new HandleErrorModel(_errorID, _errorNumber)
                {
                    ErrorMessage = string.Empty,
                    ErrorTrace   = string.Empty
                };
                return(View(ErrorHandlerAttribute.ErrorGeneralView, _error));
            }
            return(View(ErrorHandlerAttribute.ErrorGeneralView));
        }
Exemple #2
0
        protected virtual ActionResult CreateActionResult(ExceptionContext filterContext, int statusCode)
        {
            var _errorData = new HandleErrorModel(filterContext.Exception);

            /* Use Utilities.IsAjaxRequest...*/
            if (!filterContext.HttpContext.Request.IsAjaxRequest())
            {
                var _ctx            = new ControllerContext(filterContext.RequestContext, filterContext.Controller);
                var _statusCodeName = ((HttpStatusCode)statusCode).ToString();

                var _viewName = SelectFirstView(_ctx,
                                                string.Format("~/Views/Error/{0}.cshtml", _statusCodeName),
                                                string.Format("~/Views/Error/{0}.cshtml", m_strErrorGeneralView),
                                                _statusCodeName,
                                                "Error");
                ActionResult _result = null;
                if (filterContext.IsChildAction)
                {
                    _result = new PartialViewResult
                    {
                        ViewName = _viewName,
                        ViewData = new ViewDataDictionary <HandleErrorModel>(_errorData),
                    };
                }
                else
                {
                    _result = new ViewResult
                    {
                        ViewName = _viewName,
                        ViewData = new ViewDataDictionary <HandleErrorModel>(_errorData),
                    };
                }
                return(_result);
            }
            else
            {
                var _jsonResult = new JsonResult()
                {
                    Data = _errorData,
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };

                return(_jsonResult);
            }
        }