在IdentityOptions中只有这个AllowedUserNameCharacters选项可以设置,难道把所有汉字全部输入进去,还有其他设置方法吗?
参考 https://github.com/aspnet/Identity/issues/1848
You'd specify all the allowed characters in the option you mention. But given the large amount of Chinese characters that's probably not going to work for you. Instead try your own UserValidator, using https://github.com/aspnet/Identity/blob/dev/src/Core/UserValidator.cs as a staring point
看源码立马就可以找到答案,把 AllowedUserNameCharacters 设置为 null 就行了
else if (!string.IsNullOrEmpty(manager.Options.User.AllowedUserNameCharacters) &&
userName.Any(c => !manager.Options.User.AllowedUserNameCharacters.Contains(c)))
{
errors.Add(Describer.InvalidUserName(userName));
}
@dudu: 谢谢