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
The warning at the top of the doc, indicating this doesn't apply to Razor Pages seems incomplete, because it makes it look as if role-based authorization doesn't apply at all to Razor Pages, but it does, only one should be aware of differences while using it, at least from my understanding.
Regarding the Authorize attribute, if we use it in the class directly, not the methods, it seems to work as expected, example:
[Authorize(Roles = "admin")]
public class IndexModel : PageModel
Another way to achieve this seems to be by using Razor Pages conventions, configured in the Startup class:
The warning at the top of the doc, indicating this doesn't apply to Razor Pages seems incomplete, because it makes it look as if role-based authorization doesn't apply at all to Razor Pages, but it does, only one should be aware of differences while using it, at least from my understanding.
Regarding the Authorize attribute, if we use it in the class directly, not the methods, it seems to work as expected, example:
Another way to achieve this seems to be by using Razor Pages conventions, configured in the Startup class:
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: