NotSupportedException: No IUserTwoFactorTokenProvider named ‘Default’ is registered.

If you have changed the AddDefaultIdentity in the Startup.cs file to AddIdentity and you receive a

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)

error when registering a user, there is a easy fix. You need to a add a AddDefaultTokenProviders() when adding identity() to services.

public void ConfigureServices(IServiceCollection services)
  {
  ………………
  services.AddIdentity<User, UserRole>()
   .AddEntityFrameworkStores<ApplicationDbContext>()
   .AddDefaultTokenProviders();
…………………….

You may also like

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.