I have the username entered from a form Which method to use if that username is unique?
Membership.FindUsersByName
or Membership.GetUser
Or any other methods?
I am asking this specifically because I didn't see a method returning bool as its common in checking unique values.
1) Validate the username field The isRequired() function to check if the username is provided. The isBetween() function to check if the length of the username is between 3 and 25 characters. The showError() and showSuccess() functions to show the error and success indicator.
To get information about a particular user, use the Membership class's GetUser method.
Text + "' and Password= '" + TextBoxSignPass. Text + "'"; SqlCommand cmd = new SqlCommand(checkUser, con); cmd. ExecuteNonQuery(); con. Close();
Membership.GetUser
has slightly better performance. Also, Membership.FindUsersByName
performes a LIKE statement if you are using SQL Membership, so it is not meant for unique names as you are trying to do.
Short answer: to get best performance and find unique names, use Membership.GetUser
!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With