相关疑难解决方法(0)

在 ASP.net core 3.0 中更改身份登录 URL

我正在尝试从以下位置更改默认登录 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)

但不知何故,这是行不通的。

c# asp.net-mvc asp.net-core asp.net-core-3.0

4
推荐指数
1
解决办法
1931
查看次数

标签 统计

asp.net-core ×1

asp.net-core-3.0 ×1

asp.net-mvc ×1

c# ×1