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.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
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.
Member
1 Points
25 Posts
IdentityHelper.SignIn fails to authenticate
Sep 02, 2016 12:23 PM|suencien|LINK
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!
Star
9831 Points
3120 Posts
Re: IdentityHelper.SignIn fails to authenticate
Sep 05, 2016 05:35 AM|Brando ZWZ|LINK
Hi suencien,
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
Member
1 Points
25 Posts
Re: IdentityHelper.SignIn fails to authenticate
Sep 13, 2016 12:54 PM|suencien|LINK
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?
Member
1 Points
25 Posts
Re: IdentityHelper.SignIn fails to authenticate
Sep 13, 2016 12:59 PM|suencien|LINK
Oh, we are using forms authentication...
Star
9831 Points
3120 Posts
Re: IdentityHelper.SignIn fails to authenticate
Sep 18, 2016 11:33 AM|Brando ZWZ|LINK
Hi suencien,
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.
Are all your user name lowercase?
Best Regards,
Brando
None
0 Points
1 Post
Re: IdentityHelper.SignIn fails to authenticate
Dec 21, 2018 10:20 AM|tjjones70|LINK
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.