小编Ahm*_*her的帖子

如何访问 blazor webassembly 中的应用程序设置

我正在尝试将 api url 保存在 appsettings 中。但是,configuration.Propertiers 似乎是空的。我不确定如何获得设置。在 program.cs 中:

public static async Task Main(string[] args)
{
   var builder = WebAssemblyHostBuilder.CreateDefault(args);
   //string url = builder.Configuration.Properties["APIURL"].ToString();
   foreach (var prop in builder.Configuration.Properties)
      Console.WriteLine($"{prop.Key} : {prop.Value}" );
   //builder.Services.AddSingleton<Service>(new Service(url));
   builder.RootComponents.Add<App>("app");
   await builder.Build().RunAsync();
}
Run Code Online (Sandbox Code Playgroud)

c# blazor blazor-client-side

8
推荐指数
6
解决办法
1万
查看次数

标签 统计

blazor ×1

blazor-client-side ×1

c# ×1