Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change login url when using asp.net 5

I am using asp.net 5 and Identity 3 to authenticate users but it always redirect to the default login url which is "Account/Login". I want to change it but there does not seem to be anywhere to set this options. I use AddIdentity() in Configure() method. Please help. Thanks

like image 274
Xiaowei.Jia Avatar asked Aug 09 '15 13:08

Xiaowei.Jia


2 Answers

Using .Net Core 1.0.0 + Identity + Facebook OAuth, the accepted answer no longer compiles. This is 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");
    });
}
like image 72
Gerardo Grignoli Avatar answered Nov 06 '22 17:11

Gerardo Grignoli


app.UseCookieAuthentication(options =>
{
    options.LoginPath = new PathString("/Admin/Login");
    options.LogoutPath = new PathString("/Admin/LogOff");
},
IdentityOptions.ApplicationCookieAuthenticationScheme
);
like image 9
Joe Audette Avatar answered Nov 06 '22 18:11

Joe Audette