.net Core 5 _userManager.RemoveFromRolesAsync error: Username 'XXXX' is invalid, can only contain letters or digits

.net Core 5 _userManager.RemoveFromRolesAsync error: Username 'XXXX' is invalid, can only contain letters or digits

我在使用 Identity 的 .Net 5.0 中有以下代码:

        var user = await _userManager.FindByIdAsync(userId);
        if (user == null)
        {
            return View();
        }
        var roles = await _userManager.GetRolesAsync(user);
        var result = await _userManager.RemoveFromRolesAsync(user, roles.ToArray());

UserID 是有效的用户 ID,returns 是有效的 user roles 已正确填充属于 user 的角色 RemoveFromRolesAsync 失败并出现以下错误:

Username 'xxx' is invalid, can only contain letters or digits.

有什么想法吗?

已添加

options.User.AllowedUserNameCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+/\"

IdentityHostingStartup.cs

注意:似乎允许的字符匹配区分大小写...