我正在尝试从以下位置更改默认登录 URL:
/Identity/Account/Login
到
/Login
我查过类似的问题,他们想出了一个类似的解决方案:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<CompanyLoginContext>(options =>
options.UseNpgsql(
Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<CompanyLoginUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<CompanyLoginContext>()
.AddDefaultTokenProviders();
services.ConfigureApplicationCookie(options =>
{
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(10);
options.LoginPath = new PathString("/Login");
options.AccessDeniedPath = new PathString("/Logout");
options.AccessDeniedPath = new PathString("/AccessDenied");
options.SlidingExpiration = true;
});
}
但不知何故,这是行不通的。
最佳答案
确保你有脚手架的身份,你可以引用here .
然后需要修改Identity/Account/Login.cshtml
像下面这样:
@page "/Login"
关于c# - 在 ASP.net core 3.0 中更改身份登录 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525775/