If we are in break mode while debugging an MVC controller event, and want to view all ModelState errors, the following command can show all error messages in immediate window:
ModelState.Where(x => x.Value.Errors.Count>0).SelectMany((x, i)=> x.Value.Errors.Select(y=> "Key: " + x.Key + ", Error: " + y.ErrorMessage)).ToList()
No comments:
Post a Comment