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:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

 

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