core中读取配置⽂件1)先看丑陋的⽅法
读取 appsettings.json  然后在 Startup 的 ConfigureServices() ⽅法中进⾏注⼊:刘璇公布二胎喜讯>王雷主演电视剧
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IConfiguration>(Configuration);
}做手账本的贴纸
2021年3月20日新闻联播控制器中读取
public class HomeController : Controller
{
private readonly IConfiguration _configuration;
public HomeController(IConfiguration configuration)
{
_configuration = configuration;
}
读取到AppSettings下的⼦节点的所有key
IConfigurationSection section = _configuration.GetSection("AppSettings");
List<string> list = new List<string>();张杨一纯
var childes = section.GetChildren();
foreach (var configSection in childes)
{
var conKey =configSection.Key;
}读取配置文件失败