using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using ServicesLab; using ServicesLab.Services; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); // An HttpClient whose BaseAddress is this app's address, so it can read files from wwwroot. builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); // Pages ask for IGreeting. Change FriendlyGreeting to FormalGreeting here and no page changes. builder.Services.AddSingleton(); // The three lifetimes. Blazor WebAssembly has one scope for the whole app, // so the scoped service lives as long as the singleton. builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddTransient(); // NavigationManager is registered by the framework. There is nothing to add for it. await builder.Build().RunAsync();