model binding
Turning parts of an HTTP request, such as route values, the query string, headers and the JSON body, into typed parameters for your handler.
In more detail
Controllers and minimal APIs both infer the source from the parameter's type and name; attributes such as [FromBody] make it explicit. Binding failures become client errors before your code runs.
Related terms
- model validation — Checking that incoming data meets the rules, such as required fields and ranges, before the application acts on it.
- route constraint — A rule inside a route template, such as :int in {id:int}, that a URL segment must satisfy for the route to match.
- query string — The part of a web address after the question mark, made of name=value pairs, such as ?state=open&limit=2.
- input formatter — The component that reads a request body in a given format, such as JSON, and deserialises it into the action's parameter type.
Taught in
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices
- Building Routes with Controllers — Modern .NET Core, C# & Enterprise Microservices
- Building Routes with Minimal APIs — Modern .NET Core, C# & Enterprise Microservices
- Comparing Controllers and Minimal APIs — Modern .NET Core, C# & Enterprise Microservices
- Integration Testing with WebApplicationFactory — Modern .NET Core, C# & Enterprise Microservices