/aspnet-core-mvc-model-binding

This article explains what is model binding in ASP.NET Core MVC and how to use its different attributes like BindNever, BindRequired, FromHeader, FromQuery, FromRoute, FromForm, FromServices, FromBody, ModelBinder, and model binding to a list of complex objects

Primary LanguageC#

ASP.NET Core MVC Model binding

This article explains what is model binding in ASP.NET Core MVC and how to use its different attributes like BindNever, BindRequired, FromHeader, FromQuery, FromRoute, FromForm, FromServices, FromBody, ModelBinder, and model binding to a list of complex objects.

What is MVC Model Binding

MVC controller action method uses Model binding to work directly with Model types, as model binding maps HTTP request data to action method parameters by name. MVC model binding will check for the value of each parameter by name and the name of the public settable property of the Model. These parameters can be primitive like string, int, or complex types. Model binders will map data between HTTP requests and models.

Model binding extract data from various sources like route, form fields of View, or query string, convert strings to .NET data type and provides this extracted data to controller and razor pages in method parameters.

Fore more detailed description and steps please visit - https://geeksarray.com/blog/aspnet-core-mvc-model-binding

Files

  1. Product Model
  2. Product Repository
  3. Product Controller

you can bind list of model objects and display in table like

ASP.NET Core MVC Model Binding to List of Objects