locked
IdentityHelper.SignIn fails to authenticate RRS feed

  • Question

  • User-484626426 posted

    Hi guys,

    I have a problem at my Login page where IdentityHelper.SignIn fails to authenticate every now and then.

    It works fine locally, but when accessed through the Internet, it fails most of the time. Sometimes it works for a few minutes after I restart the IIS. I tried two different machines and end up the same.

    I have googled this and did not find any answer. The only thing I can think of is the slow upload connection speed. It's 0.78 Mbps.

    Has anyone had the same issue before?

    Thank you guys!

    Friday, September 2, 2016 12:23 PM

All replies

  • User283571144 posted

    Hi suencien,

    I have googled this and did not find any answer. The only thing I can think of is the slow upload connection speed. It's 0.78 Mbps.

    Has anyone had the same issue before?

    According to your description, we can’t find the reason caused this issue.

    Could you please post more about error message?

    Do you use windows authentication or forms authentication?

    Besides, I suggest you could check the IIS log file to find the reason.

    More details, you could refer to follow link:

    https://msdn.microsoft.com/en-us/library/ms525410(v=vs.90).aspx

    Best Regards,

    Brando

    Monday, September 5, 2016 5:35 AM
  • User-484626426 posted

    I Brando,

    Thank you for your response. Sorry for replying late :)

    There are no error messages. User.Identity.IsAuthenticated will just return false despites the right user name and password.

    Sometimes, authentication works for a while after we restart the IIS.

    UserManager manager = new UserManager();
    ApplicationUser user = manager.Find(txtUserName.Text.ToLower(), txtPassword.Text);

    IdentityHelper.SignIn(manager, user, cbxRememberMe.Checked);
    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);

    Nor

    IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
    System.Security.Claims.ClaimsIdentity userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

    authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = cbxRememberMe.Checked }, userIdentity);

    Same results.

    When the site is accessed locally, the authentication problem happens a lot less.

    Any ideas mate?

    Tuesday, September 13, 2016 12:54 PM
  • User-484626426 posted

    Oh, we are using forms authentication...

    Tuesday, September 13, 2016 12:59 PM
  • User283571144 posted

    Hi suencien,

    suencien

    There are no error messages. User.Identity.IsAuthenticated will just return false despites the right user name and password.

    Since this issue is no error messages and sometimes works well, I suggest you could use Visual Studio to check your codes to make sure it has value.

    I suggest you could set a breakpoint at this line to check the user has value, firstly.

    ApplicationUser user = manager.Find(txtUserName.Text.ToLower(), txtPassword.Text);

    Are all your user name lowercase?

    Best Regards,

    Brando

    Sunday, September 18, 2016 11:33 AM
  • User539373078 posted

    I don't know if you still need this, but what worked for me was changing my connection string name in web.config that Identity is using from "DefaultConnection" to anything else. Just not "DefaultConnection". You can create a new connection string with same variables and then change the Identity reference in App_code/IdentityModels.vb/cs. I was able to duplicate the problem by changing it back to "DefaultConnection". Good Luck.

    Friday, December 21, 2018 10:20 AM