Blazor WASM PWA app - email account confirmation. Please help

Posted 172 days ago by Francois
Edited 172 days ago

Hi All

I have created a blazor WASM PWA .Net6 application that allows a user to register with some basic details.

Once the user registers the application sends a email confirmation link with a link and token to validate the email address.

This is all working fine in production I can register and confirm email via the link provided. 

When I host the application on my local machine IIS the application works but when I register a new account and use the email confirmation link I keep getting a message saying "Sorry, there's nothing at this address."

this is happening on all the pages that uses "return View("xyz"). Even when I use the passwords reset function that also returns a view I get the same message  "Sorry, there's nothing at this address.". This is only happening on controllers that returns a view and it is only happening when the app is hosted. I don't see any errors in DEV tools in chrome. When I click on the email confirmation link it takes me to the correct page using this link:



but displayed:   "Sorry, there's nothing at this address.".  if I do a ctrl+F5 it completes the email confirmation process and all is fine. But I cannot understand why I have to do a refresh "CTRL+F5" to complete the email confirmation or password reset this is only when the app is hosted and its only on Return View all other razor pages are working as expected.


My account controller to generate the link on login uses the following code:

var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

var confirmationLink = Url.Link("Confirmation", new { token, email = user.Email });

await _emailSender.SendEmailAsync(user.Email, "Account Confirmation Link - CrimeLogger",

 $"Please confirm your account by clicking <a href=\"" + confirmationLink + "\">here</a>");


The email is sent and I use the email link to confirm registration:

The link points to the following controller:


[Route("ConfirmEmail", Name = "Confirmation")]



   public class EmailController : Controller


       private readonly UserManager<ApplicationUser> _userManager;


       public EmailController(UserManager<ApplicationUser> userManager)


           _userManager = userManager;




       public async Task<IActionResult> ConfirmEmail(string token, string email)


           var user = await _userManager.FindByNameAsync(email);

           if (user == null)

               return View("Error");

           var result = await _userManager.ConfirmEmailAsync(user, token);

           if (result.Succeeded)


               return View("ConfirmedEmail");




               return View("emailconfirmerror");



   it should load the view below: but it does not, only after CTRL+F5 does it load the below view. Any suggestions on where I can look to try and resolve this error. Remember this only happens when the app is hosted and only on Views I have cleared the browser cash and tried again but still same situation


@using Common

@using Microsoft.AspNetCore.Components

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers


   ViewData["Title"] = "ConfirmedEmail";


@inject NavigationManager NavigationManager


<!DOCTYPE html>

<html lang="en">



   <meta charset="utf-8" />

   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />


   <link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />

   <link href="~/css/app.css" rel="stylesheet" asp-append-version="true" />




   <div class="row col-md-12" style="place-content:center;text-align:center">


   <div class="card border">

       <div class="card-body">

           <h3 class="col-12 text-black text-center py-2">

               Welcome to XYZ 



               <p>Thank you for confirming your email. Please log in <a href="@SD.TempLink">here</a>.









Thank you


  • 0

    I'm not sure why it works differently locally than on the server, but when you refresh, does the URL change at all?  Is it maybe causing the encoded string to decode, then processing it okay?  

    Try adding the following just above the line that has _userManager.ConfirmEmailAsync (user, token);

    token = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(token));

    This would url decode the string before it tries to confirm it, in case that's the issue.

    Posted 172 days ago by selliott
  • 0



    I tried adding the line suggested, if I do that it renders the -  return View("emailconfirmerror"); so the error view returns correctly. I then changed it back to inspect the url again and to compare the failed one with the refreshed version after ctrl+F5 and the 2 are identical

    failed/ before ctrl+f5


    success after ctrl+F5



    the fact that it returned the error view page stunned me, as both the emailconfirmerror view page and the confirmedemail view pages are identical except for the message body <p> tag. I am stunned I just cant seem to find the issue here. Both pages are located in the same subfolder under Views folder in my app. I even tried different browsers now and still the same issues.

    do you know if there is any other way I might be able to debug this issue??, of all the complexity in this app this is thing that's not working it killing my brain.. lol



    Posted 172 days ago by Francois
  • 0

    If your issue is on the live website and not the local version, why does the URL have https://localhost in it?

    Edit: Nevermind, I just re-read and see that the issue is local and not on the production server.

    Posted 172 days ago by selliott Edited 172 days ago
  • 0

    I am hosting it locally on my pc using IIS.

     If I run it in debug mode in Visual Studio 2022 I don't have any issues.

    Posted 172 days ago by Francois
  • 0

    Perhaps it's related to IIS then.  I could be wrong, but I believe debug mode may run in Kestrel.

    Posted 172 days ago by selliott
  • 0

    I think it is. I'm going to register the domain and setup the hosting etc. and see if  I run into the same issues. I hope not. Difficult to find sites to host for testing purposes, do you know of any? 

    Posted 172 days ago by Francois
  • 0

    If you launch the app by going to your Server directory in command line and launch it with "dotnet watch" (should open the browser automatically) or "dotnet run" and open the browser manually, I suspect it will run fine then too.

    Azure offers free tiers for testing purposes.  You can add an App Service to host an app and just choose the free tier.  It has limited resources, but is fine for testing.

    Posted 172 days ago by selliott
  • 0

    Perfect thank you. I will let you know if the issue is with IIS if the hosted version works on azure. Thanks again for the assistance 

    Posted 172 days ago by Francois
Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 1
An error has occurred. This application may no longer respond until reloaded. Reload 🗙