ASP.NET - Membership Login - Asked By rajesh kokul on 17-Apr-13 08:59 AM

Hello All,

I am trying to authenticate user by Membership even i enter correct user name and password the authentication get false.
Have checked in database whether the related user is locked out but its fine locked out is false.Same thing tried for newly created 4 users bt result same.

This is my code :

Boolean bauthenticated = false;
bauthenticated = isValidUser(UserName, Password);

Please suggest me any solution...Thanks in advance

-Rajesh K
Danasegarane Arunachalam replied to rajesh kokul on 20-Apr-13 03:33 AM
You should use the Membership.ValidateUser method.

Example :

public void Login_OnClick(object sender, EventArgs args)
{
   if (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))
      FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked);
   else
     Msg.Text = "Login failed. Please check your user name and password and try again.";
}


Refer MSDN : http://msdn.microsoft.com/en-IN/library/system.web.security.membership.validateuser.aspx