I am using membership api to fetch the user password and email.
I have got this code:
MembershipUser currentUser = Membership.GetUser();
UserPasssword.Text = currentUser.GetPassword(); //Null exception
I need to check the user at the login. The problem is that the user isnt login. So I thought to find a way to fetch the user password or email with the membership api and not through the a database query. Is there a way to do it? or do I have to resort to a database query?
Remember that the user isnt logged in .. .. So the result will be null point exception each time on the currentUser object..
How can check his email with the membership api and then use a redirection:
if (currentUser.Email == LoginEmail.Text && currentUser.GetPassword() == hash)
{
FormsAuthentication.RedirectFromLoginPage(currentUser.UserName, false);
}
else
{
LoginFail.Text = "Email or Password havent been incorrect.";
}
If you’re just trying to log the user in, you’d be better off letting membership handle it via the Validate User method.