NotSupportedException No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered

While modifying .NET Core's Identity files, I stumbled upon this error: NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.

The Microsoft.AspNetCore.Identity.UserManager<TUser>.GenerateUserTokenAsync function couldn't generate a token because no provider was available upon registering a new user. This error has an easy fix though!

If you're like me, you changed AddDefaultIdentity in the Startup.cs file to AddIdentity. I wanted to implement my own user that inherited from the base user. By doing this I lost the default token providers. The fix was to add them back with AddDefaultTokenProviders().

            services.AddIdentity<User, UserRole>()

After that fix, everything worked again!

Matt Ferderer

Software enginner who spends his time learning about building teams, project management, software architecture, C#, .NET Core, Blazor, JavaScript, TypeScript, Azure, user experience, web security, and performance.