C# 来自不同web应用的.NET Core 3 UserManager/IdentityUser问题
我有两个内置在.NETCore3.1中的web应用程序,带有razor页面。 第一个具有在Startup.cs中初始化的用于身份验证的标准net core标识C# 来自不同web应用的.NET Core 3 UserManager/IdentityUser问题,c#,razor,asp.net-identity,core,C#,Razor,Asp.net Identity,Core,我有两个内置在.NETCore3.1中的web应用程序,带有razor页面。 第一个具有在Startup.cs中初始化的用于身份验证的标准net core标识 services.AddDefaultIdentity<IdentityUser>(options => { options.User.RequireUniqueEmail = true; options.SignIn.RequireConf
services.AddDefaultIdentity<IdentityUser>(options =>
{
options.User.RequireUniqueEmail = true;
options.SignIn.RequireConfirmedAccount = true;
options.SignIn.RequireConfirmedEmail = true;
})
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<context>();
这两个应用共享同一个数据库
services.AddDbContext<context>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
但如果我尝试更改密码、ResetPasswordAsync或GeneratePasswordResetTokenAsync之类的操作,我总是会遇到如下错误:
An unhandled exception occurred while processing the request.
NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.
处理请求时发生未处理的异常。
NotSupportedException:未注册名为“Default”的IUSERTwoFactoryTokenProvider。
我不明白的是我是否遗漏了什么或者我的方法完全错误
UserManager<IdentityUser> userManager =
new UserManager<IdentityUser>(
new UserStore<IdentityUser>(context);,
identityOptions, //same of startup.cs from first site
new PasswordHasher<IdentityUser>(),
new List<UserValidator<IdentityUser>>() { new UserValidator<IdentityUser>() },
new List<PasswordValidator<IdentityUser>>() { new PasswordValidator<IdentityUser>() },
new UpperInvariantLookupNormalizer(),
new IdentityErrorDescriber(),
null,
null);
var user = await userManager.FindByIdAsync(SOMEID);
An unhandled exception occurred while processing the request.
NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.