Asp.NET Identity stops working in Chrome

For some unknown reason, I can no longer log into my application in Chrome.

Here is how I sign up:

    [AllowAnonymous]
    [HttpPost]
    public async Task<ActionResult> Login(LoginModel model)
    {
        if (User.Identity.IsAuthenticated)
            return RedirectToAction("Index", "Home");

        if (!ModelState.IsValid)
            return View();

        var status = await signInManager.PasswordSignInAsync(model.Login, model.Password, true, false);
        switch (status)
        {
            case Microsoft.AspNet.Identity.Owin.SignInStatus.Success:
                {
                    int userId = User.Identity.GetUserId<int>();
                    if (userManager.IsFirstLogin(userId))
                    {
                        return RedirectToAction("Declaration", "Home", new { returnUrl = model.ReturnUrl });
                    }

                    return RedirectToLocal(model.ReturnUrl);
                }
            default:
                return View();
        }
    }

I debugged the code and PasswordSignInAsync succeeded, however Chrome does not show a cookie for the page. In fact, redirecting to an action that is marked with the [Authorize] attribute redirects again to the login page.

I tested the site on IE and everything works correctly, I can log in and out, and the cookie is set correctly.

If I can provide more details, just tell me.


Edit: Details

, ( ). 01 2016 , , . .

, , , cookie . "", .

+4
1

, , "" cookie Auth.

Startup.Auth.cs:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    CookieName = $"SomeCustomNameForAuthCookie",
    Provider = ...
}); 

, - cookie .

0

Source: https://habr.com/ru/post/1627504/


All Articles