1.VS 2022:New ASP.NET Core Web (Model-Model-Controller)
2.Install-Package Otp.NET, Install-Package QRCoder
3.HomeController.cs
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using Web.Models;
using OtpNet;
using QRCoder;
using System.Text;
1.VS 2022:New ASP.NET Core Web (Model-Model-Controller) 2.Install-Package Otp.NET, Install-Package QRCoder 3.HomeController.cs using Microsoft.AspNetCore.Mvc; using System.Diagnostics; using Web.Models; using OtpNet; using QRCoder; using System.Text;
public class HomeController : Controller { private readonly ILogger _logger;
private const string Secret = "JBSWY3DPEHPK3PXP";
private const string BaseUser = "test";
private const string Issuer = "demo";
} 4.Views/Home/Index.cshtml @{ ViewData["Title"] = "Home Page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <img src="/Home/Qrcode" style="width: 300px;" /> <form action="/Home/Validate" method="post"> Code: <input name="code" /> <input type="submit" value="Validate" /> </form> </div> 5.run 6.Scan the QR code using APP Authenticator 7.Enter totp code, VerifyTotp always fails