[英]How to customize ASP.NET Identity Core Username to allow special characters and space while registering
I would like to use some special characters like ø, in the user name. 我想在用户名中使用一些特殊字符,例如ø。 I have set the
AllowOnlyAlphanumericUserNames = false
, but i'm getting an error like as below. 我已经设置了
AllowOnlyAlphanumericUserNames = false
,但是出现如下错误。
User name tew-wer is invalid, can only contain letters or digits.
用户名tew-wer无效,只能包含字母或数字。
Can you please help me to solve this. 你能帮我解决这个问题吗?
in startup.cs
configure identity services to include allowed chars in user name: 在
startup.cs
将身份服务配置为在用户名中包含允许的字符:
services.AddIdentity<AppUser, AppRole>(ops =>
{
//--- other code
ops.User.AllowedUserNameCharacters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.