When I try to create a User with the UserManager and there are characters like ä, ö, ü in the UserName, I get a succeeded=false. I don’t understand why it is a problem. The DB is nvarchar (255) and should not have a problem with German characters. I can change it afterword by using the DbContext. How can I change this behavior?
Asked
Active
Viewed 186 times
1 Answers
2
Usermanager
validates the username by checking if there is any character not contained in the list of allowed characters. You can change that list:
services.Configure<IdentityOptions>(options =>
{
// The list of allowed characters in the username used to validate user names
// you can add German characters here
options.User.AllowedUserNameCharacters
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
});
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

tmg
- 19,895
- 5
- 72
- 76
-
Thanks Mate. Also fixes a problem i had restricting some signs. :) – Sknecht Sep 22 '16 at 10:21