In Startup.cs file you have modified services.AddDefaultIdentity to services.AddIdentity .
When calling GenerateEmailConfirmationTokenAync for example or any other identity function, if you receive the following error:
An unhandled exception occurred while processing the request.
NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named ‘Default’ is registered. Microsoft.AspNetCore.Identity.UserManager<TUser>.GenerateUserTokenAsync(TUser user, string tokenProvider, string purpose)
Here is the fix : Add a AddDefaultTokenProviders() when adding identity() to services like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity(config =>
{
//config.Password.
config.User.RequireUniqueEmail = true; // email
config.User.AllowedUserNameCharacters = "myexyzcodsecret";
config.SignIn.RequireConfirmedEmail = true;
}).AddEntityFrameworkStores<ApplicationDbContext>()
//the fix is below
.AddDefaultTokenProviders();
}
AddDefaultTokenProviders(); is the fix