Form data is a named field value submitted in the body of an HTTP request when an HTML form uses POST. In Razor Pages, model binding turns matching form values into PageModel properties or handler parameters. section 16.2
Razor Pages processes form data as part of model binding:
- The model binder checks form values, route values, and query string values in that order, using the first matching value. section 16.2
- Bound values are validated and assigned to PageModel properties or passed to page-handler parameters. section 16.2
- Razor Pages binds form bodies by default, unlike minimal APIs, which do not support the same default form-body binding behavior. section 16.2
Listing 16.1 Model binding requests to properties in a Razor Page
public class IndexModel: PageModel
{
[BindProperty] #1
public string Category { get; set; } #1
[BindProperty(SupportsGet = true)] #2
public string Username { get; set; } #2
public void OnGet()
{
}
public void OnPost(ProductModel model) #3
{
}
}
The example shows form-bound properties alongside a page-handler parameter, illustrating two ways submitted values can reach Razor Page code. section 16.2


