I’m experiencing a problem where I must enter my credentials twice in order to log into my Webmatrix site (which is based on the webmatrix sample site). I go to my log in screen and enter my credentials then an error appears stating “There was a problem
with your login and/or errors exist in your form.” Then if I click the link to the log in page again and enter me credentials again, I am able to log in successfully. Any ideas as to why this happens?!?!?!
if (Roles.IsUserInRole(username, "Admin")){
Response.Redirect("~/Default_Admin.cshtml");
}
if (Roles.IsUserInRole(username, "Director")){
Response.Redirect("~/Default_Director.cshtml");
}
if (Roles.IsUserInRole(username, "Volunteer")){
Response.Redirect("~/Default_Volunteer.cshtml");
}
lgviii
Member
3 Points
3 Posts
Must Log In Twice?
Jun 11, 2012 03:10 AM|LINK
Hi!
I’m experiencing a problem where I must enter my credentials twice in order to log into my Webmatrix site (which is based on the webmatrix sample site). I go to my log in screen and enter my credentials then an error appears stating “There was a problem with your login and/or errors exist in your form.” Then if I click the link to the log in page again and enter me credentials again, I am able to log in successfully. Any ideas as to why this happens?!?!?!
Thanks!
This is my log in code:
if (isValid) {
if (WebSecurity.UserExists(username) && WebSecurity.GetPasswordFailuresSinceLastSuccess(username) > 4 && WebSecurity.GetLastPasswordFailureDate(username).AddSeconds(60) > DateTime.UtcNow ) {
Response.Redirect("~/account/AccountLockedOut");
return;
}
if (WebSecurity.Login(username, password, rememberMe)) {
if (Roles.IsUserInRole("Admin"))
{
Response.Redirect("~/Default_Admin.cshtml");
}
if (Roles.IsUserInRole("Director"))
{
Response.Redirect("~/Default_Director.cshtml");
}
if (Roles.IsUserInRole("Volunteer"))
{
Response.Redirect("~/Default_Volunteer.cshtml");
}
}
isValid = false;
}
rickj1
Member
385 Points
203 Posts
Re: Must Log In Twice?
Jun 11, 2012 04:44 AM|LINK
Is your site live if it is check the url when you are asked to login the second time to make sure you are still
on your site and not on a phising site
www.barterlinks.net
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Must Log In Twice?
Jun 11, 2012 07:39 AM|LINK
Try this:
if (Roles.IsUserInRole(username, "Admin")){ Response.Redirect("~/Default_Admin.cshtml"); } if (Roles.IsUserInRole(username, "Director")){ Response.Redirect("~/Default_Director.cshtml"); } if (Roles.IsUserInRole(username, "Volunteer")){ Response.Redirect("~/Default_Volunteer.cshtml"); }Web Pages CMS | My Site | Twitter
sunilbanakar
Member
189 Points
70 Posts
Re: Must Log In Twice?
Jun 14, 2012 11:14 AM|LINK
Hai
May be you are sending the messagebox event on button click check for it.
If you are putting session time check for it.
May be your page may be reloading it within that time and textbox values are cleared in that time .
Thank you
lgviii
Member
3 Points
3 Posts
Re: Must Log In Twice?
Jun 17, 2012 04:43 AM|LINK
Ahhhh, so it looks like the username that .InUserRole looked at wasn't initialized at the time of the call, but then would be on the second page load.
*embarrassing*
Thanks for the help!