Пример #1
0
        protected StandardJsonResult JsonError(string errorMessage)
        {
            var result = new StandardJsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            result.AddError(errorMessage);

            return(result);
        }
Пример #2
0
        protected StandardJsonResult JsonValidationError()
        {
            var result = new StandardJsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            foreach (var validationError in ModelState.Values.SelectMany(v => v.Errors))
            {
                result.AddError(validationError.ErrorMessage);
            }
            return(result);
        }