【发布时间】:2021-05-29 13:18:20
【问题描述】:
我是 .NET Core 的新手,从我在网络上的搜索中看到,appsettings.Development.json 用于开发应用程序时的开发配置,appsettings.Production.json 用于生产服务器中已发布的应用程序。这是我在两者上设置的示例部分:
appsettings.Development.json:
"ConnectionStrings": {
"DefaultConnection": "Server=localhost,21433;Initial Catalog=DemoDbDev;User Id=demouser;Password=******;"
},
appsettings.Production.json:
"ConnectionStrings": {
"DefaultConnection": "Server=demo-prod-db,1433;Initial Catalog=DemoDbProd;User Id=demouser;Password=******;"
},
这里有一些我需要澄清的问题:
1) appsettings.json 的用途是什么?它是用于默认配置还是用于不在appsettings.Development.json 或appsettings.Production.json 中的其他设置?
2) 环境是否设置在Properties 文件夹中的launchSettings.json 上?如果是这样,我们是否应该在将应用发布到生产服务器之前手动更新此文件?
3) 在开发和发布我的应用程序(到 IIS 服务器或 Docker 容器)时,关于开发和生产环境配置有什么需要注意的吗?
任何帮助将不胜感激。
【问题讨论】:
标签: c# docker asp.net-core iis .net-core