liveBook · Manning

SupportsGet

As explained in ASP.NET Core in Action, 3e

SupportsGet is a BindProperty setting that permits a Razor Pages property to receive values during GET request model binding.

SupportsGet is a BindProperty setting that opts a Razor Pages property into model binding for HTTP GET requests. Without it, [BindProperty] properties are not populated during GET requests. section 15.3 section 16.2

Bind a query value during GET

Decorate the property with [BindProperty(SupportsGet = true)]. In the example, a GET request can populate Username, while Category remains unbound because it uses ordinary [BindProperty]. The OnGet handler can then use the populated property. section 15.6

Keep these model-binding details in mind:

  • Treat GET binding as an explicit opt-in; binding is restricted by default for security reasons. section 16.2
  • Give the bound property a public setter, or model binding silently fails. section 16.2
  • Use SupportsGet for request values supplied through model binding, while handler parameters remain another way to receive request values. section 15.3

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains the opt-in attribute setting, public-setter requirement, and security rationale without detailing binder internals.
Examples
Contrasts Username using SupportsGet with Category using ordinary BindProperty in a Razor Page model.
What it assumes
Assumes familiarity with Razor Pages properties and BindProperty while explaining GET binding behavior from the basics.
What you can do after
Apply SupportsGet to opt a Razor Pages property into GET model binding and recognize a missing public setter.
How it connects
Connects SupportsGet with BindProperty, model binding, GET requests, page handlers, and request binding sources.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.