ASP.NET Core tries toautomatically populate (set values of their properties and fields) any parameters of an action method. This happens because it has a built-in (although configurable)model binder provider, which creates amodel binder. These model binders know how to bind data from the many binding sources (discussed previously) to POCO classes in many formats.
Model binders
The model binder provider interface is IModelBinderProvider and the model binder, unsurprisingly, is IModelBinder. The model binder providers are registered in the ModelBinderProviders collection of MvcOptions:
services.AddMvc(options =>
{
options.ModelBinderProviders.Add(new CustomModelBinderProvider());
});
The included providers are as follows:
- BinderTypeModelBinderProvider: Custom model binder (IModelBinder)
- ServicesModelBinderProvider: [FromServices]
- BodyModelBinderProvider: [FromBody]
- HeaderModelBinderProvider...