【发布时间】:2018-11-23 17:48:12
【问题描述】:
我已经创建了几个这样的 .net core 2 web 应用程序,直到这个没有问题。
在 IISExpress 下本地运行它可以正常运行,但是当我将调试版本部署到服务器上的 IIS 文件夹时出现问题。
当我阅读配置条目时找不到它:
_config["MySettings:MyName"];
文件内容:
appsettings.Development.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Trace",
"System": "Information",
"Microsoft": "Information"
}
},
"MySettings": {
"MyName": "JohnDoe"
}
}
appsettings.json
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Trace"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
launchSetting.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60668/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/security",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApi.ViewerSecurity": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/security",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:60669/"
}
}
}
如果我复制 appsettings.Development.json 并重命名为 appsettings.Production.json 它可以工作。
我更改了 prod 文件中“MyName”的值并记录了它。是的,从 appsettings.Production.json 读取。
如何以及为什么?生产在任何地方都没有定义。
【问题讨论】:
标签: asp.net asp.net-core .net-core asp.net-core-2.0