.Net Core读取配置文件和读取不同环境下的appsettings.json
.NET Core的appsettings.json配置文件与之前.NET Framework采用xml的config文件不同,目前主要是采用json文件键值对配置方式读取。
读取配置文件
引入扩展 System.Configuration.ConfigurationManager读取App.config/Web.config
https://www.cnblogs.com/RainFate/p/12082497.html
引入扩展 Microsoft.Extensions.Options.ConfigurationExtensions
Nuget 下载扩展,使用方式:参考微软官网:https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/index?view=aspnetcore-3.0
Install-Package Microsoft.Extensions.Options.ConfigurationExtensions Install-Package Microsoft.Extensions.Configuration.FileExtensions Install-Package Microsoft.Extensions.Configuration.Json
个人示例地址
https://github.com/RainFate/Demo/tree/master/Sol_NetCoreDemo/Sol_NetCoreReadConfig
读取不同环境下的appsettings.json
https://www.cnblogs.com/myzony/p/9418858.html
https://github.com/RainFate/Demo/blob/master/Sol_NetCoreDemo/Sol_NetCoreReadConfig/Startup.cs