天天看點

NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named ‘Default‘ is registered問題

問題

NotSupportedException: No IUserTwoFactorTokenProvider named ‘Default’ is registered.

原因:startup檔案缺少配置

在 public void ConfigureServices(IServiceCollection services)方法中添加如下配置
ervices.AddIdentity<IdentityUser, IdentityRole>(options =>
{
   services.AddIdentity<ApplicationUser, IdentityRole>(options =>
    {
       options.Password = new PasswordOptions()
      {
        RequireNonAlphanumeric = false,
        RequireUppercase = false
     };
   }).AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();