You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
We want to create a new attribute [BindProperty] which means that the property should be model bound.
We'll have an override via a property bool SupportsGet which enables binding of the properties for GET requests.
Placing the attribute on a class means that it applies to all public properties in the class. This has overriding behavior - the attribute on the property wins. There is no way to un-bind a property if you use the attribute at the class level.
This new attribute should go in the RazorPages namespace. Features like SupportsGet aren't relevant to controllers.
Examples:
public class Index : PageModel
{
[BindProperty]
public string CustomerName { get; set; } // This property is only bound for non-GET requests
}
public class Search : PageModel
{
[BindProperty(SupportsGet = true)]
public string Query { get; set; } // This property is bound for all requests
}
[BindProperty(SupportsGet = true)]
public class Search : PageModel
{
public string Query { get; set; } // This property is bound for all requests
public bool ImFeelingLucky { get; set; } // This property is bound for all requests
}