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

Method Attribute on Razor Pages. #7842

Closed
Bartmax opened this issue May 31, 2018 · 2 comments
Closed

Method Attribute on Razor Pages. #7842

Bartmax opened this issue May 31, 2018 · 2 comments
Labels

Comments

@Bartmax
Copy link

Bartmax commented May 31, 2018

Is this a Bug or Feature request?:

Question / Feature request

Description of the problem:

public class MyPageModel : PageModel {
  [HttpGet]
  [Authorize] // does nothing
  public void OnGet() { }

  [HttpPost]
  [AllowAnonymous] // does nothing
  public async Task<ActionResult> OnPost()
}

Is it possible to use attributes per method on Razor Pages ?
(i know the code provided does not work)
If it doesn't, I suggest an error or warning as it may lead to filter sensitive data.

@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @Bartmax.
The Authorize attribute is not applicable to page handlers. You can apply it on the page model level, though.
This is a quesiton which keeps coming up and we plan to provide a guidance here by introducing an analyzer, which will work developers from doing that: #7684

@Bartmax
Copy link
Author

Bartmax commented May 31, 2018

is a quesiton which keeps coming up

that suggests this issue should be treated as Feature Request then 😄

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

No branches or pull requests

2 participants