Setting up a new solution with .net core 3.0 and trying to edit the startup to go to my area.
/Identity/Account/Login Area: Identity Controller: Account View: Login
Tried:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "/identity/account/login");
endpoints.MapRazorPages();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{area:identity}/{controller:account}/{action=login}");
endpoints.MapRazorPages();
});
If only authenticated user can access your application, you can provide a policy in the call to AddAuthorization
.The DefaultPolicy
is initially configured to require authentication, so no additional configuration is required:
public void Configure(IApplicationBuilder app)
{
...
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute().RequireAuthorization();
});
}
MVC endpoints are marked as RequireAuthorization
so that all requests must be authorized based on the DefaultPolicy. Reference: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#authorization
So if not authenticated, user will be redirect to asp.net identity's login page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.