0

I am using Identity.Owin to log the user in for me. Using standard generated code.

protected void LogIn(object sender, EventArgs e)
{
    if (IsValid)
    {
        // Validate the user password
        var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
        var signinManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();

        // This doen't count login failures towards account lockout
        // To enable password failures to trigger lockout, change to shouldLockout: true
        var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false);

        switch (result)
        {
            case SignInStatus.Success:
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                break;
            case SignInStatus.LockedOut:
                Response.Redirect("/Account/Lockout");
                break;
            case SignInStatus.RequiresVerification:
                Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}", 
                                                Request.QueryString["ReturnUrl"],
                                                RememberMe.Checked),
                                  true);
                break;
            case SignInStatus.Failure:
            default:
                FailureText.Text = "Invalid login attempt";
                ErrorMessage.Visible = true;
                break;
        }
    }
}

It works perfectly on my local machine, the strange thing is it works on the server ONLY after I publish the log in. If I clear my cookies it doesn't log in anymore.

It just sends me back to the login page with no errors.

My theory is, it is server related. The application pool isn't keeping sessions or it is because it is an insecure site because google chrome does say the following:

enter image description here

Not finding anything on google or even sure what to google. Any Ideas or guidance would be much appreciated.

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
Anarchy101
  • 315
  • 1
  • 2
  • 8

1 Answers1

0

After painful debugging and recycling the application pool to be able to log in, it turns out that logging out or when the cookie expires OWIN doesn't remove the cookie properly (see this related question on OWIN authentication signout).

Tagc
  • 8,736
  • 7
  • 61
  • 114
Anarchy101
  • 315
  • 1
  • 2
  • 8