This guide explains how to completely remove Multi-Factor Authentication (MFA/2FA) from your application.
In appsettings.json, remove or set to false:
// DELETE or set to false:
"Authentication": {
"EnableMfa": false, // DELETE THIS LINE
...
}
In Pages/Account/Login.cshtml.cs, remove the MFA redirect logic in OnPostAsync:
// DELETE this section:
if (result.RequiresTwoFactor)
{
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
}
Delete these files from Pages/Account/:
LoginWith2fa.cshtml and .cshtml.csLoginWithRecoveryCode.cshtml and .cshtml.csDelete these files from Pages/Account/Manage/:
EnableMfa.cshtml and .cshtml.csDisableMfa.cshtml and .cshtml.csShowRecoveryCodes.cshtml and .cshtml.csIn Pages/Account/Manage/Index.cshtml, remove the MFA section:
<!-- DELETE: Two-Factor Authentication section -->
<div class="card mb-3">
<div class="card-header">Two-Factor Authentication</div>
<!-- ... entire card ... -->
</div>
In Pages/Account/Manage/Index.cshtml.cs, remove:
Is2faEnabled, IsMachineRemembered, etc.)OnGetAsyncIf you have MFA-related startup validation, remove those checks.
Delete these files and folders:
wwwroot/help/mfa/ (entire folder)wwwroot/help/user/mfa-setup.htmIn wwwroot/help/index.htm, delete the MFA section.
In wwwroot/help/default.htm, remove the MFA link from the user help.
If you want to clear existing MFA data:
-- Optional: Disable MFA for all users
UPDATE AspNetUsers
SET TwoFactorEnabled = 0;
-- Optional: Remove authenticator keys and recovery codes
DELETE FROM AspNetUserTokens
WHERE Name = 'RecoveryCodes' OR Name = 'AuthenticatorKey';
After removal, verify: