How can I use email instead of user name in the new ASP.NET identity system?
I tried to change the RegisterViewModel
class:
[Display(Name = "Email address")]
[Required(ErrorMessage = "The email address is required")]
[EmailAddress(ErrorMessage = "Invalid Email Address")]
public string UserName { get; set; }
but when I enter an mail adress I am getting the error:
User name [email protected] is invalid, can only contain letters or digits.
You have 2 options to solve it by either turning off that validator, or create your own UserValidator.
You could turn it off like this:
UserManager.UserValidator = new UserValidator<TUser>(UserManager)
{
AllowOnlyAlphanumericUserNames = false
};
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments