In this post we will discuss on how we can Logging in users programmatically in Asp.Net. Also you can check out my previous posts on:
You can use pre-built mechanics of the Login control or you can also perform this task programmatically using the Membership class. To validate credentials that you receive, you use the ValidateUser() method of this class. The ValidateUser() method takes a single signature:
Membership.ValidateUser(username As String, password As String)
Validating a user’s credentials programmatically
If Membership.ValidateUser(TextBox1.Text, TextBox2.Text) Then
Label1.Text = “You are not registered with the site.”
if (Membership.ValidateUser(TextBox1.Text, TextBox2.Text)
Label1.Text = “You are not registered with the site.”;
The ValidateUser() method returns a Boolean value of True if the user credentials pass the test and False if they do not.
you can see that end users whose credentials are verified as correct are redirected from the login page using the RedirectFromLoginPage() method. This method takes the username and a Boolean value that specifies whether the credentials are persisted through a cookie setting.