I am updating a Blazor web assembly project from .NET 9 to .NET 10, and noticed a change in behavior with the following line of code:
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
In .NET 9, when using this mode without prerendering, lifecycle methods such as OnInitialized and OnInitializedAsync were executed normally on the client.
In .NET 10, however, these lifecycle methods are no longer triggered.
Does anyone know how to make them launch the same way as in the previous frameworks?
I've tried every possible option and I don't understand why Microsoft doesn't allow this in .NET 10!
@page "/"
@using System.Security.Claims
@using shared_library.Layout
@using webapp_blazor.Client.Servicios;
@layout LayoutRaiz
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
@inject Servicio_AuthenticationStateProvider_Wasm _Servicio_AuthenticationStateProvider
@inject NavigationManager _NavigationManager
@code {
protected async override Task OnInitializedAsync()
{
var authenticationState = await _Servicio_AuthenticationStateProvider.GetAuthenticationStateAsync();
ClaimsPrincipal _ClaimsPrincipal = authenticationState.User;
/*Otra forma de comprobar si esta validado*/
if (!authenticationState.User.Identity.IsAuthenticated)
{
_NavigationManager.NavigateTo("/Autenticar_wasm");
}
else
{
_NavigationManager.NavigateTo("/Inicio_wasm");
}
}
protected async override void OnAfterRender(bool firstRender)
{
var authenticationState = await _Servicio_AuthenticationStateProvider.GetAuthenticationStateAsync();
ClaimsPrincipal _ClaimsPrincipal = authenticationState.User;
/*Otra forma de comprobar si esta validado*/
if (!authenticationState.User.Identity.IsAuthenticated)
{
_NavigationManager.NavigateTo("/Autenticar_wasm");
}
else
{
_NavigationManager.NavigateTo("/Inicio_wasm");
}
}
}