First off, I don't have the reputation to post comments or "like" an existing post: Client program.cs is never executed when creating Blazor WebAssembly apps in .net 8
However, I am experiencing this same issue and my server program.cs contains this code:
app.MapRazorComponents<App>() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode() .AddAdditionalAssemblies(typeof(Lexican.Client._Imports).Assembly);The server project handles all the login & identity processing and then redirects back to the client where I use services to get the data needed.
As soon as I login & redirect back to the client, none of the injected services are available because the client program.cs did not execute.
My client program.cs is NOT executing at all... I added a breakpoint and even on an anonymous session, it is not fire.Here is the code:
global using MudBlazor.Services;global using MudBlazor;global using Microsoft.AspNetCore.Authorization;using Blazored.LocalStorage;using Microsoft.AspNetCore.Components.Authorization;using Microsoft.AspNetCore.Components.WebAssembly.Hosting;using Microsoft.AspNetCore.Identity;var builder = WebAssemblyHostBuilder.CreateDefault(args);builder.Services.AddSingleton<AuthenticationStateProvider, PersistentAuthenticationStateProvider>();builder.Services.AddSingleton<IAdminService, AdminService>();builder.Services.AddSingleton<IWordService, WordService>();builder.Services.AddSingleton<IStudentTestService, StudentTestService>();builder.Services.AddSingleton<IUserClaimsPrincipalFactory<ApplicationUser>, UserClaimsPrincipalFactory<ApplicationUser, IdentityRole>>();builder.Services.AddSingleton<IEventMessages, EventMessages>();builder.Services.AddBlazoredLocalStorageAsSingleton();builder.Services.AddSingleton<ICommonMethods, CommonMethods>(); builder.Services.AddBlazoredLocalStorage(); builder.Services.AddAuthorizationCore();builder.Services.AddCascadingAuthenticationState();builder.Services.AddMudServices();var app = builder.Build();// Create a loggervar logger = app.Services.GetRequiredService<ILogger<Program>>();// Log service registrationsbuilder.Services.LogServiceRegistrations(logger);await app.RunAsync();This is quite likely a configuration issue, but I can't find it.
What can I check or change next? What else do you need to see before you can offer help?