How to change login url when using asp.net 5

I use asp.net 5 and Identity 3 to authenticate users, but it always redirects to the default login URL, which is β€œAccount / Login”. I want to change it, but there seems to be no need to set these parameters anywhere. I am using the AddIdentity () method in Configure (). Please help. Thanks

+6
source share
4 answers
app.UseCookieAuthentication(options => { options.LoginPath = new PathString("/Admin/Login"); options.LogoutPath = new PathString("/Admin/LogOff"); }, IdentityOptions.ApplicationCookieAuthenticationScheme ); 
+6
source

Using .Net Core 1.0.0 + Identity + Facebook OAuth, the accepted answer no longer compiles. Here's what worked:

 public void ConfigureServices(IServiceCollection services) { (...) services.Configure<IdentityOptions>(options => { options.Cookies.ApplicationCookie.LoginPath = new PathString("/Login"); options.Cookies.ApplicationCookie.LogoutPath = new PathString("/Logoff"); }); } 
+12
source

With ASP.NET Core 1.1 + Identity, I use this:

 public void ConfigureServices(IServiceCollection services) { (...) services.AddIdentity<ApplicationUser, IdentityRole>(x => { x.Cookies.ApplicationCookie.LoginPath = new PathString("/Admin/Login"); x.Cookies.ApplicationCookie.LogoutPath = new PathString("/Admin/LogOff"); } } 
+3
source

From ASP.NET Core 2.0 + Identity, this has changed to:

 services.ConfigureApplicationCookie(options => options.LoginPath = "/Account/LogIn"); 

Read more about moving to 2.0 here .

+1
source

All Articles