2FA QR code is not generating in Blazor Web app.

Diwakar Devangam 30 Reputation points

using Blazor Web App template and authentication type as individual accounts, 2FA is not generating the QR code. Is this need to be fixed?

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
4,526 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,217 questions
{count} votes

Accepted answer
  1. Ruikai Feng - MSFT 1,836 Reputation points Microsoft Vendor

    Hi,@Diwakar Devangam

    You have to add the required js file/js codes yourself follow this document:

    Download the qrcode.js JavaScript library to the wwwroot\lib folder in your project.

    Create a new JavaScript file called qr.js in wwwroot/js and add the following code to generate the QR Code:

    window.addEventListener("load", () => {
      const uri = document.getElementById("qrCodeData").getAttribute('data-url');
      new QRCode(document.getElementById("qrCode"),
          text: uri,
          width: 150,
          height: 150

    Refer the required js file in EnableAuthenticator.cshtml:

    @section Scripts {
        @await Html.PartialAsync("_ValidationScriptsPartial")
        <script type="text/javascript" src="~/lib/qrcode.js"></script>
        <script type="text/javascript" src="~/js/qr.js"></script>

    It works as expected on myside:

    User's image

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Ruikai Feng

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful