I am creating a dotnetcore 2.1 application and have scaffolded the Identity Login page. However, I don't know how to make the login page the startup page. I know how to do it with Controllers and Actions but not with the scaffolded page. Please could someone enlighten me on how to do this ?
As Brendan Green wrote in the comments you can add a restriction in your startup.cs file.
This works in Asp.Net Core 2.0 and 2.1.
You can do this by use the following code in your startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(o =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
o.Filters.Add(new AuthorizeFilter(policy));
});
}
If you want to do this you need a user-store. So you have to use the template with individual user accounts or you do with "new Scaffolded item" -> "identity"
I hope this help you?
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.