Ever wondered just what the ModelState was that keeps popping up in your ASP.NET MVC controllers? So did I. Let’s break down what the ModelState is and why we use it.

What is ModelState?
ModelState is a property of a Controller, and can be accessed from those classes that inherit from System.Web.Mvc.Controller.

The ModelState represents a collection of name and value pairs that were submitted to the server during a POST. It also contains a collection of error messages for each value submitted. Despite its name, it doesn’t actually know anything about any model classes, it only has names, values, and errors.

ModelState has two purposes: to store the value submitted to the server, and to store the validation errors associated with those values.

#asp.net mvc #modelstate

Explaining the ModelState in ASP.NET MVC
10.65 GEEK