Skip to content

RequireAuthorization with Razor Pages #17300

@gpshonik

Description

@gpshonik

Some clarification about using the .RequireAuthorization() extension method with razor pages would be appreciated.

Specifically this section:

The DefaultPolicy is triggered by [Authorize] or RequireAuthorization, while the FallbackPolicy is triggered when no other policy is set. FallbackPolicy is initially configured to allow requests without authorization.

The DefaultPolicy does not appear to trigger with endpoints.MapRazorPages().RequireAuthorization(); like it does with endpoints.MapDefaultControllerRoute().RequireAuthorization();

For razor pages, either a FallbackPolicy or an authorization convention like services.AddRazorPages(opt => opt.Conventions.AuthorizeFolder("/")) appears to be necessary.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesinvestigate

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions