Part-3 | Asp.Net Core Identity Series[.NET 7] | Sending Two-Factor Authentication(2FA) Code To Email
The main objectives of this article are: Sending Two-Factor Authentication(2FA) Code To Email Enable Email 2FA: In Asp.Net Core Identity application to enable email Two-Factor Authentication, make sure our 'AspNetUser' table following fields has appropriate data: Email - Should not be empty or null EmailConfrimed - must be true TwoFactorEnabled - must be true. Now if we try to login into our application we can see a page to enter the 2FA code like below Send Two-Factor Authentication(2FA) Code To Email: Now let's update the code in 'OnGetAsync()' method in 'Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs' as below. Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs: public async Task<IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null) { // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); if (user == null) { throw ne