Model Binding in ASP.NET Core is the process that automatically maps incoming HTTP request data (from query strings, forms, route data, headers, or body) to
action method parameters or model properties in controller actions.
Key Purpose
To reduce manual data parsing. Instead of reading request data explicitly (like from
Request.Form["name"]), ASP.NET Core binds the data directly to method parameters or objects.
Example
public class UserModel
{
public string Name { get; set; }
public int Age { get; set; }
}
[HttpPost]
public IActionResult Submit(UserModel user)
{
// ASP.NET Core binds form or JSON body to 'user' automatically
return Ok(user);
}
If the request contains:
{
"name": "Alice",
"age": 25
}
The user parameter is automatically populated.
Sources of Data for Model Binding
ASP.NET Core looks in the following places, in order:
Route Data
Query String
Form Data
Request Body (for [FromBody])
Headers
Services (via [FromServices])
You can explicitly specify a source using attributes:
Attribute
Source
[FromQuery]
URL query string
[FromRoute]
Route parameters
[FromForm]
Form data
[FromBody]
JSON/XML body
[FromHeader]
HTTP headers
[FromServices]
Dependency injection
Model Binding vs. Model Validation
Model Binding maps data.
Model Validation checks if the data is valid (e.g., required fields, value ranges) using attributes like
[Required], [Range], etc.
Summary
Model Binding is automatic in ASP.NET Core.
It maps HTTP request data to C# parameters or model classes.
Supports multiple data sources and is extensible.
Reduces boilerplate code and simplifies input handling.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Model Binding in ASP.NET Core is the process that automatically maps incoming HTTP request data (from query strings, forms, route data, headers, or body) to action method parameters or model properties in controller actions.
Key Purpose
To reduce manual data parsing. Instead of reading request data explicitly (like from
Request.Form["name"]), ASP.NET Core binds the data directly to method parameters or objects.Example
If the request contains:
The
userparameter is automatically populated.Sources of Data for Model Binding
ASP.NET Core looks in the following places, in order:
[FromBody])[FromServices])You can explicitly specify a source using attributes:
[FromQuery][FromRoute][FromForm][FromBody][FromHeader][FromServices]Model Binding vs. Model Validation
[Required],[Range], etc.Summary