ASP.NET Core Identity更改登录URL

问题描述 投票:8回答:3

我正在使用ASP.NET Core 2.1并且我使用脚手架来添加Identity,这是正常工作除了当我尝试转到需要登录的页面时,它需要我:/Identity/Account/Login?ReturnUrl

如何更改它以转到/我的帐户/登录,这是我自己创建的登录页面。

我试过这个:

services.ConfigureApplicationCookie(options =>
                {
                    options.AccessDeniedPath = "/Account/AccessDenied";
                    options.Cookie.Name = "Cookie";
                    options.Cookie.HttpOnly = true;
                    options.ExpireTimeSpan = TimeSpan.FromMinutes(720);
                    options.LoginPath = "/Account/Login";
                    options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
                    options.SlidingExpiration = true;
                });

但它仍然是/ Identity /

.net asp.net-core .net-core asp.net-identity
3个回答
4
投票

如果您有以下内容,请检查如何注册身份服务

services.AddDefaultIdentity<IdentityUser>(options => { }) .AddEntityFrameworkStores<ApplicationDbContext>();

用它替换它

services.AddIdentity<IdentityUser, IdentityRole>(options => { }) .AddEntityFrameworkStores<ApplicationDbContext>(); 并将你的代码保存在我的案例中的ConfigureApplicationCookie中。


4
投票

我刚遇到同样的问题。我通过移动我解决了它

qazxsw poi在我的qazxsw poi召唤之后打电话给qazxsw poi


3
投票

尝试添加services.ConfigureApplicationCookie并在控制器中设置路线。

services.AddIdentity
© www.soinside.com 2019 - 2024. All rights reserved.