bcw*_*ger 3 .net c# asp.net-core asp.net-core-webapi
我有一个 .NET Core 2.0 Web API,它无法读取环境特定的 app.settings 文件。据我所知,我已遵循所有相关步骤。
这是我的Startup.cs构造函数:
public Startup(IHostingEnvironment env)
{
var config = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个appsettings.json文件结构:
appsettings.json
-appsettings.debug.json
-appsettings.release.json
-appsettings.production.json
Run Code Online (Sandbox Code Playgroud)
在部署我的 API 的服务器上,我有一个系统环境变量键/值对
Variable = ASPNETCORE_ENVIRONMENT Value = Release
但是,当我调用 API 时,appsettings.production.json会使用这些值,这(据我所知)ASPNETCORE_ENVIRONMENT是未找到环境变量 of 时的默认值。
关于我的设置可能缺少什么导致这种默认行为的想法?
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |