This code will help you to understand how to access the appsettings in Blazor WebAssembly.
Configurations loaded by the Blazor WebAssembly can be accessed by injecting IConfiguration services. Using IConfiguration, the values from wwwroot/appsettings.json and wwwroot/appsettings.{ENVIRONMENT}.json files can be accessed.
wwwroot/appsettings.json
{ "message": "Blazor is awesome." }
Index.razor
@inject Microsoft.Extensions.Configuration.IConfiguration config <span>@config["message"]</span>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Configurations loaded by the Blazor WebAssembly can be accessed by injecting IConfiguration services. Using IConfiguration, the values from wwwroot/appsettings.json and wwwroot/appsettings.{ENVIRONMENT}.json files can be accessed.
wwwroot/appsettings.json
Index.razor
need an explanation for this answer? contact us directly to get an explanation for this answer