Use email as username in ASP.NET LogIn Control

I want to use the normal ASP.NET application login system, but I want to use the user's email address as the username (as is common on many websites.) However, there seems to be no property or attribute allowing me to do anything- something like that; The username and email address always appear separate. Is it possible to do this or does it require some kind of complicated setup? Thanks.

+6
login forms-authentication
source share
3 answers

I assume that you are talking about the CreateUserWizard control.

In the designer, right-click the CreateUserWizard control and select Customize User Creation Step. This will remove the email field string. I also recommend adding RegularExpressionValidator to check the email format for the username.

To copy a username to an email address, handle the CreateUser event and execute it:

protected void CreateUserWizard1_CreatingUser( object sender, LoginCancelEventArgs e ) { CreateUserWizard1.Email = CreateUserWizard1.UserName; } 
+7
source share

Having done the same for several websites, it turned out that the easiest way is to use the email address for the UserName and EmailAddress fields, instead of trying to change the membership API to use the existing EmailAddress field on top of UserName.

+6
source share

To do this, you wrote your custom membership provider. To do this, you inherit the membership provider class and must create your own membership provider.

Here are some good links for you.

http://www.15seconds.com/issue/050216.htm

Here is a link for good discussions.

http://forums.asp.net/t/1146571.aspx

+1
source share

All Articles