How to use ASP.NET Membership class to validate users in VB.NET

The Membership class provides a method for validating a membership user. If a user has entered his user name and password in a login mask, you can use the ValidateUser() method for programmatically validating the information entered by the user, as follows:

 

Protected Sub LoginAction_Click(sender As Object, e As EventArgs) Handles LoginAction.Click

If Membership.ValidateUser(UsernameText.Text, PasswordText.Text) Then

FormsAuthentication.RedirectFromLoginPage(UsernameText.Text, False)

Else

LegendStatus.Text = “Invalid user name or password!”

End If

End Sub