小编Jac*_*ier的帖子

ASP.NET Core appsettings.json 未加载正确的设置

在我的 Azure 中,我有ENVIRONMENT = Development,但我的设置未加载。

public static IConfiguration Configuration { get; } = new ConfigurationBuilder()
       .SetBasePath(Directory.GetCurrentDirectory())
       .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) // reloadOnChange Whether the configuration should be reloaded if the file changes.
       .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
       .AddEnvironmentVariables() // Environment Variables override all other, ** THIS SHOULD ALWAYS BE LAST
       .Build();
Run Code Online (Sandbox Code Playgroud)

但它始终使用默认设置。

c# asp.net-core asp.net-core-webapi asp.net-core-configuration

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