Cal*_*man 4 c# asp.net-mvc asp.net-core asp.net-core-3.0
我正在尝试从以下位置更改默认登录 URL:
/Identity/Account/Login
Run Code Online (Sandbox Code Playgroud)
到
/Login
Run Code Online (Sandbox Code Playgroud)
我查过类似的问题,他们想出了一个类似的解决方案:
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;
});
}
Run Code Online (Sandbox Code Playgroud)
但不知何故,这是行不通的。
确保你有脚手架的身份,你可以参考这里。
然后你需要修改Identity/Account/Login.cshtml如下:
@page "/Login"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1931 次 |
| 最近记录: |