Model binding and validation
Model binding and validation are features of ASP.NET Core MVC that help simplify getting data from HTTP requests like GET
or POST
and ensure it meets specific criteria before processing.
Model binding is the process by which data from HTTP requests like form fields, query strings, route data, or the body of a POST
or PUT
request is automatically mapped to .NET models. This allows you to work with strongly typed objects in the controllers instead of dealing with raw HTTP data.
When an HTTP request is received, ASP.NET Core inspects the request data and attempts to bind it to the parameters of the action method or the properties of a model object. For example, if you have a form that posts data to a controller action, the fields in the form are automatically mapped to the parameters of that action or a model class, as long as the names match.
ASP.NET Core is capable of binding complex objects that have properties matching the incoming data. For example, if you...