I can't use email as Username with MVC5 Microsoft.AspNet.Identity

Problem:

I want to use email as the username with Microsoft.AspNet.Identity in MVC 5 application. But when I do I get the following error:

User name ... is invalid, can only contain letters or digits.

Solution:

In the AccountController constructor that takes a userManager as a parameter add the following code:

UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager)
 { AllowOnlyAlphanumericUserNames = false };
Comments are closed