I dont know why but the page /Generador/VerificarEmail/EncriptedEmailAndName is executed twice. ChatGPT suggested me to put all the code as async, so I did that but the page is still executing twice.
The page is to verify an email when a new user try to register in my web page and the link to access is put in a email that I send to the future user
Do anyone know where is the issue?Here is my Blazor page code
@page "/Generador/VerificarEmail/{EncriptedEmailAndName}"@using FiyiStackWeb2.Areas.Generator.AccountBack.Entities;@using FiyiStackWeb2.Areas.Generator.AccountBack.Repositories;@inject AccountRepository accountRepository;@inject NavigationManager NavigationManager;<PageTitle>Verificar email - FiyiStack</PageTitle><FiyiStackWeb2.Components.Layout.NavBarHome></FiyiStackWeb2.Components.Layout.NavBarHome><div class="page-header align-items-start min-vh-100" style="background-image: url('/img/FiyiStackWeb2/Generador-Crear-Cuenta.png');" loading="lazy"><span class="mask bg-gradient-dark opacity-6"></span><div class="container my-auto"><div class="row"><div class="col-lg-4 col-md-8 mx-auto"><div class="card z-index-0"><div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2"><div class="bg-gradient-success shadow-success border-radius-lg py-3 pe-1"><h4 class="text-white font-weight-bolder text-center mt-2 mb-0"> Verificar correo</h4></div></div><div class="card-body"> @if (Message != "") { @((MarkupString)Message) }<div class="text-center"><button type="button" class="btn bg-gradient-dark w-100 my-4 mb-2"><i class="fas fa-door-open fa-xl"></i> Login</button></div></div></div></div></div></div></div><FiyiStackWeb2.Components.Layout.FooterHome></FiyiStackWeb2.Components.Layout.FooterHome>@code { [Parameter] public string EncriptedEmailAndName { get; set; } = ""; public string Message { get; set; } = ""; protected override async Task OnInitializedAsync() { try { if (string.IsNullOrEmpty(EncriptedEmailAndName)) { Message = $@"<div class=""alert alert-warning text-white font-weight-bold"" role=""alert""> Código encriptado para validar no proporcionado</div>"; return; } Account? AccountToVerify = await accountRepository.GetByEncriptedEmailAndNameAsync(EncriptedEmailAndName); if (AccountToVerify == null) { Message = $@"<div class=""alert alert-warning text-white font-weight-bold"" role=""alert""> Cuenta inexistente</div>"; return; } else { if (AccountToVerify.IsEmailVerified == true) { Message = $@"<div class=""alert alert-warning text-white font-weight-bold"" role=""alert""> Esta cuenta ya se encuentra verificada</div>"; return; } else { AccountToVerify.IsEmailVerified = true; await accountRepository.UpdateAsync(AccountToVerify); Message = $@"<div class=""alert alert-warning text-white font-weight-bold"" role=""alert""> Cuenta verificada correctamente</div>"; } } } catch (Exception ex) { Failure failure = new() { Active = true, DateTimeCreation = DateTime.Now, DateTimeLastModification = DateTime.Now, UserCreationId = 1, UserLastModificationId = 1, EmergencyLevel = 1, Comment = "", Message = ex.Message, Source = ex.Source, StackTrace = ex.StackTrace }; await failureRepository.AddAsync(failure); } finally { //Re-render the page to show ScannedText await InvokeAsync(() => StateHasChanged()).ConfigureAwait(false); } }}