I am trying to use the Blazorise frontend components library(https://blazorise.com/docs/start/) In section 4a I am to add the code in Program.cs;
builder.Services.AddSingleton( new HttpClient
{
BaseAddress = new Uri( builder.HostEnvironment.BaseAddress )
} );
This gives me the error: "WebAssemblyHostBuilder" does not contain a definition for HostEnvironment and not accessible extension method 'HostEnvironment' accepting a first argument of type WebAssemblyHostBuilder
Any suggestions how to fix this?
This is all of the code in Program.cs: '''
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services
.AddBlazorise(options =>
{
options.ChangeTextOnKeyPress = true;
})
.AddBootstrapProviders()
.AddFontAwesomeIcons();
builder.Services.AddSingleton(new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
builder.RootComponents.Add<App>("app");
var host = builder.Build();
host.Services
.UseBootstrapProviders()
.UseFontAwesomeIcons();
await host.RunAsync();
}
}
''' Note: This is a Blazor WebAssembly ASP.NET Core hosted project