Model binding
Model binding is a standard ASP.NET Core process that maps data from incoming HTTP requests to strongly typed models used in controller actions and views.
Sitecore ASP.NET Core SDK developers use model binding to connect SitecoreAI content to their ASP.NET Core application's models. Specifically, to connect the data from the Experience Edge response to strongly typed model objects. For example, you can directly bind a text field named Title in your SitecoreAI content to a string property named Title in your model.
This makes rendering model-bound views easy, and it allows developers to work with SitecoreAI content in a more structured and type-safe manner.
Model binding using the ASP.NET Core SDK
The ASP.NET Core SDK provides ASP.NET Core model binding support for key objects, properties, and fields that Experience Edge returns in a SitecoreLayoutResponse object.
Model binding is done with Sitecore.AspNetCore.SDK.RenderingEngine.Binding.Attributes. If a model property is not mapped through attributes, the default ASP.NET Core model binding behavior takes over.
The attributes, sources, and providers are located in the Sitecore.AspNetCore.SDK.RenderingEngine.Binding namespace.
Model properties that implement IField do not require explicit attributes. They bind to the current component or the current route field of the same name.
The current component, response, or route refers to the corresponding objects in the SitecoreLayoutResponse instance that are available as context information on the HttpContext object. For a given request, the current response and route are the same for all components, but the placeholder tag helper sets the current component dynamically.
Example
Here's an example response from Experience Edge:
For this response, here's a matching view model class: