This is my razor component page:
@page "/SignIn"
@inject INotificationService _localStorage
@inject NavigationManager _navigationManager
@inject IAuthenticationService _authService
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
...
@code {
public bool PageLoading { get; set; }
private Models.Notification? Notification { get; set; } = null;
public SignInRequestDto SignInRequest { get; set; } = new();
public bool IsAuthFailed { get; set; }
public string ReturnURL { get; set; }
public string Error { get; set; }
protected override async Task OnInitializedAsync()
{
PageLoading = true;
StateHasChanged();
System.Threading.Thread.Sleep(3000);
await GetNotification();
PageLoading = false;
}
...
So when I am on the Home page and I click "Se connecter" (that means sign in), the page does not goes to the signIn page, but instead stall on the Home page executing the OnInitializeAsync of the SignIn and then when it is finish, it shows finally the SingIn page.
I was expected that prerender: false will fix this but it does nothing.
This is the MainLayout that will redirect to the /SignIn page.
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inject NavigationManager Navigation
Hello, @context.User.Identity?.Name!
Se déconnecter
Se connecter
@code{
public void BeginLogOut()
{
Navigation.NavigateToLogout(Routes.Disconnect);
}
}
This is the demo:
https://drive.google.com/file/d/15fd0P8a4cuyH1F6rg8B6CN7MBfeSVk16/view?usp=sharing
/>
I expect that I will see the Loading component and the right page (/signin) instead of waiting on page Home before OnInitializeAsync is finished.
Render mode does not work properly on blazor web assembly .NET 8
Programing Coderfunda
February 29, 2024
No comments
Related Posts:
Laravel Jetstream: Add CRUD with Spatie Permission Laravel Jetstream is a starter kit that helps you not only with Auth scaffolding but with extra functionality like Teams or Two-Factor Authentic… Read More
Laravel Route Grouping: 6 Techniques to Organize Routes Laravel Routing is the feature that developers learn from the very beginning. But as their projects grow, it's getting harder to manage evergrow… Read More
How to get a Websites Favicons in Laravel There may be times in your Laravel applications where you want to display a favicon from another website. For example, you could have a link to … Read More
Eloquent Performance: 4 Examples of N+1 Query Problems Eloquent performance is typically the main reason for slow Laravel projects. A big part of that is a so-called "N+1 Query Problem". In this arti… Read More
Restructuring a Laravel Controller using Services, Events, Jobs, Actions, and more One of the top Laravel questions I hear is "How to structure the project". If we narrow it down, the largest part of it sounds like "If the logi… Read More
0 comments:
Post a Comment
Thanks