How to get all Errors from ASP.Net MVC modelState?
I want to get all the error messages out of the modelState without knowing the key values. Looping through to grab all the error messages that the ModelState contains. How can I do this? Oren Trutner foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { DoSomethingWith(error); } } See also How do I get the collection of Model State Errors in ASP.NET MVC? . mmutilva Using LINQ : IEnumerable<ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); Building on the LINQ verison, if you want to join all the error messages into