IdentityServer4踩坑,User name '' is invalid, can only contain letters or digits的解决方式

 

 因为用户名带有中文,在indetity Server4中报错。

解决办法:

 public IAbpSession AbpSession { get; set; }

        private readonly TenantManager _tenantManager;
        private readonly UserManager _userManager;
        private readonly RoleManager _roleManager;
        private readonly IPasswordHasher<User> _passwordHasher;

        public UserRegistrationManager(
            TenantManager tenantManager,
            UserManager userManager,
            RoleManager roleManager,
            IPasswordHasher<User> passwordHasher)
        {
            _tenantManager = tenantManager;
            _userManager = userManager;
            _roleManager = roleManager;
            _passwordHasher = passwordHasher;

            _roleManager.RoleValidators.Clear();
            userManager.UserValidators.Clear();
            AbpSession = NullAbpSession.Instance;
        }

_roleManager.RoleValidators.Clear();
userManager.UserValidators.Clear();

加入以上代码即可解决中文报错问题。

posted @ 2021-06-23 13:43  Dark华  阅读(729)  评论(0编辑  收藏  举报