Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Create a new attribute for Pages property binding #6091

Closed
@rynowak

Description

@rynowak

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
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions