Search code examples
c#asp.net-identityasp.net-core-mvc

ASP Identity in MVC6 - Login Path property not working


After updating from beta 5 to beta 8 I can't set my custom login path in cookie authentication options.

services.AddCookieAuthentication(config =>
{
    config.LoginPath = "/Auth/Login";
    //or
    //config.LoginPath = new Microsoft.AspNet.Http.PathString("Auth/Login");
});

This value is completely ignored. Still gets redirected to the default '/Account/Login'. Is there any other options to set this path?


Solution

  • It seems that now you should do this a bit differently (worked for me):

    services.Configure<IdentityOptions>(options=>
    {
        options.Cookies.ApplicationCookie.LoginPath = new Microsoft.AspNet.Http.PathString("/Auth/Login");
    });
    

    From here.