我遇到一个问题,即我无法使用as.net核心身份创建新用户,而我正在使用核心3.1。 每当我尝试执行代码时,都会出现此错误:
”执行请求时发生未处理的异常。 System.IndexOutOfRangeException:索引超出数组的范围。“
我听不懂。请找到我的代码:
private readonly UserManager<ApplicationUser> _userManager;
private readonly RoleManager<IdentityRole> _roleManager;
private readonly IApplicationDbContext _context;
public IdentityService(UserManager<ApplicationUser> userManager, RoleManager<IdentityRole>
roleManager, IApplicationDbContext context)
{
_userManager = userManager;
_roleManager = roleManager;
_context = context;
}
var user = new ApplicationUser
{
FirstName = firstName,
LastName = lastName,
UserName = userName,
Email = emailId
};
try
{
var result = await _userManager.CreateAsync(user, password); // here my code breaks
}
catch (Exception ex)
{
throw ex;
}