ModelState
ModelState is an ASP.NET Core representation of request model-binding and validation state, including bound values and associated errors.
ASP.NET Core in Action, 3e
ModelState is the ASP.NET Core request-state dictionary that stores bound values and validation errors associated with properties or the model.
- How it is used
- Checks request validity before page-handler or controller logic and supports validation-error responses.
- How deep it goes
- Explains automatic validation, handler checks, form redisplay, an action filter, and manually populated state in unit tests.
- Examples
- Uses a checkout form, a validation action filter, and a currency controller test to illustrate ModelState handling.
- What you can do after
- Apply it via ASP.NET Core to handle invalid requests and test validation-failure paths.
Pro ASP.NET Core 7, Tenth Edition
ModelStateDictionary is the ASP.NET Core MVC collection that stores bound model values and validation errors for request fields and properties.
- How it is used
- Gates use of bound request objects and carries errors to MVC views or web API responses.
- How deep it goes
- Defines ModelStateDictionary and its principal members, then works through implicit checks, explicit property rules, and controller tests.
- Examples
- Uses an RSVP form, empty-cart checkout tests, positive-price checks, and a product API returning validation errors.
- What you can do after
- Apply it via ASP.NET Core MVC to reject invalid submissions, add rule-specific errors, and return errors through views or API responses.
Read how Pro ASP.NET Core 7, Tenth Edition explains ModelState →
Building Web APIs with ASP.NET Core
ModelState is the ASP.NET Core representation of model-binding and validation state, including associated errors for an HTTP request.
- How it is used
- Coordinates model-binding and validation outcomes before ASP.NET Core API actions process HTTP requests.
- How deep it goes
- Explains the binding-validation lifecycle and manual configuration, but defers the internal structure of ModelState entries.
- Examples
- Uses custom validation messages, pageSize-specific HTTP 501 handling, and conditional HTTP 403 or HTTP 400 responses.
- What you can do after
- Diagnose invalid request input automatically or configure manual inspection for customized validation responses.
Read how Building Web APIs with ASP.NET Core explains ModelState →
What to know first
- model bindingModel binding is the process of locating incoming data, converting it to appropriate types, and assigning it to application objects or handler parameters.
Related concepts
- ModelState.AddModelErrorused by · ModelState.AddModelError is an ASP.NET Core MVC operation that adds a validation error associated with a model key or field.
- manual model validationused by · Manual model validation is the explicit inspection of bound request data and validation errors within application code before producing a response.
- validation summaryused by · A validation summary is a form-interface element or rendering mechanism that displays validation messages associated with a form or its fields.
- validationproduced by · Validation is the process of checking data, behavior, or results against defined criteria to determine their correctness, acceptability, or suitability for a purpose.
Questions about ModelState
What is ModelState?
ModelState is an ASP.NET Core representation of request model-binding and validation state, including bound values and associated errors.
Which Manning books explain ModelState?
ASP.NET Core in Action, 3e, Pro ASP.NET Core 7, Tenth Edition and Building Web APIs with ASP.NET Core.
What should I know before learning ModelState?
Manning books that teach ModelState usually introduce model binding and validation error first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


