Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best method to check if username already exist in forms authentication

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.

like image 910
naveen Avatar asked Feb 05 '11 09:02

naveen


People also ask

How to check if username already exists in database using javascript?

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.

What will you do to find out whether a user is a member of a particular role in a website that uses ASP Net Membership control for creation of user accounts?

To get information about a particular user, use the Membership class's GetUser method.

How to Validate username and password in c#?

Text + "' and Password= '" + TextBoxSignPass. Text + "'"; SqlCommand cmd = new SqlCommand(checkUser, con); cmd. ExecuteNonQuery(); con. Close();


1 Answers

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!

like image 63
Bebben Avatar answered Oct 02 '22 02:10

Bebben