Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
/MvcPublic archive
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 propertybool 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 toun-bind a property if you use the attribute at the class level.

This new attribute should go in the RazorPages namespace. Features likeSupportsGet 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


    [8]ページ先頭

    ©2009-2025 Movatter.jp