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

FromRouteAttribute doesn't seem to work in Razor Pages #6402

Closed
sebastienros opened this issue Jun 16, 2017 · 4 comments
Closed

FromRouteAttribute doesn't seem to work in Razor Pages #6402

sebastienros opened this issue Jun 16, 2017 · 4 comments

Comments

@sebastienros
Copy link
Member

sebastienros commented Jun 16, 2017

[FromRoute]
public string Foo {get;set;}

With this route:

@page "{Foo}"

Foo is empty, however I can access the value with RouteData.Values["Foo"]

@NTaylorMullen NTaylorMullen changed the title FromRouteAttribute doesn't seem to work in RP FromRouteAttribute doesn't seem to work in RazorPages RP Jun 16, 2017
@NTaylorMullen NTaylorMullen changed the title FromRouteAttribute doesn't seem to work in RazorPages RP FromRouteAttribute doesn't seem to work in Razor Pages Jun 16, 2017
@pranavkm
Copy link
Contributor

Is this on a GET request? We don't execute any model binders by default for GET requests. You have to explicitly annotate the property to state this:

[BindProperty(SupportsGet =  true)]
[FromRoute]
public string Foo { get; set; }

@sebastienros
Copy link
Member Author

Then you can close if it's by design.

But do you mean it's model bound for some other verbs?

@rynowak
Copy link
Member

rynowak commented Jun 19, 2017

We're going to take some action here to make pages 100% consistent with controllers.

rynowak added a commit that referenced this issue Jun 26, 2017
This changeset reckonciles the binding work we did for pages with
controllers.

A quick summary:
- Moves [BindProperty] to the MVC namespace (#6401)
- Makes [FromRoute] and friends behave consistently (#6402)
- Makes [BindProperty] work with controllers (untracked)
rynowak added a commit that referenced this issue Jun 27, 2017
This changeset reckonciles the binding work we did for pages with
controllers.

A quick summary:
- Moves [BindProperty] to the MVC namespace (#6401)
- Makes [FromRoute] and friends behave consistently (#6402)
- Makes [BindProperty] work with controllers (untracked)
@rynowak
Copy link
Member

rynowak commented Jun 27, 2017

0ad9c7d

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants