Live Chat Icon For mobile
Live Chat Icon

How do I access the appsettings in Blazor WebAssembly?

Platform: Blazor| Category: General

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>

More information about configuration can be found here.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.