Parameter binding
Parameter binding is the process that converts request data (i.e., URL paths, query strings, or the body) into strongly typed parameters that can be consumed by route handlers. ASP.NET Core minimal APIs support the following binding sources:
- Route values
- Query strings
- Headers
- The body (as JSON, the only format supported by default)
- A service provider (dependency injection)
We’ll talk in detail about dependency injection in Chapter 4, Implementing Dependency Injection.
As we’ll see later in this chapter, if necessary, we can customize the way in which binding is performed for a particular input. Unfortunately, in the current version, binding from Form
is not natively supported in minimal APIs. This means that, for example, IFormFile
is not supported either.
To better understand how parameter binding works, let’s take a look at the following API:
var builder = WebApplication.CreateBuilder(args); builder.Services...