当我尝试使用UserManager创建用户并且UserName中包含ä,ö,ü之类的字符时,我得到了成功= false。我不明白为什么会这样。DB是nvarchar(255),德语字符应该没有问题。我可以使用DbContext更改后记。我该如何改变这种行为?
Usermanager
通过检查允许的字符列表中是否包含任何字符来验证用户名。您可以更改该列表:
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();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句