public ActionResult Er404(string msg)
        {
            var ex = new EntityNotFoundException();

            if (Request.IsAjaxRequest())
            {
                var json = new JsonHttpStatusResult(ex.ExceptionData, ex.HttpStatus);
                json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                return(json);
            }
            return(View(ex.ExceptionData));
        }
        protected virtual ActionResult CreateActionResult(ExceptionContext filterContext, HttpStatusCode statusCode)
        {
            var ctx            = new ControllerContext(filterContext.RequestContext, filterContext.Controller);
            var statusCodeName = statusCode.ToString();



            var    controllerName = (string)filterContext.RouteData.Values["controller"];
            var    actionName     = (string)filterContext.RouteData.Values["action"];
            var    model          = new HandleErrorInfo(filterContext.Exception, controllerName, actionName);
            var    ex             = (model.Exception as AppException) == null ? null : (model.Exception as AppException).ExceptionData;
            string viewName       = null;

            try
            {
                viewName = SelectFirstView(ctx,
                                           string.Format("~/Views/Errors/{0}.cshtml", statusCodeName),
                                           "~/Views/Errors/Error.cshtml",
                                           statusCodeName,
                                           "Error");
            }
            catch (InvalidOperationException)
            {
                //view not found
                viewName = null;
            }
            //if ajax request
            if (filterContext.HttpContext.Request.IsAjaxRequest() || string.IsNullOrEmpty(viewName))
            {
                var json = new JsonHttpStatusResult(ex, statusCode);
                json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                return(json);
            }
            //else render view
            else
            {
                var result = new ViewResult
                {
                    ViewName = viewName,
                    ViewData = new ViewDataDictionary <ExceptionModelBase>(ex),
                };
                result.ViewBag.StatusCode = statusCode;
                return(result);
            }
        }