Net Core 读取json文件

一种是网上常见的一种

  var builder1 = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
  var configuration = builder1.Build();
  string baseUrl = configuration.GetSection("ConnectionStrings:xxx").Value;

另外一种是

var config = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                        //.AddEnvironmentVariables()
                         .Build();
            Configuration = config.GetSection("ConnectionStrings:xxx");

 

Net Core 读取json文件

上一篇:idea中war和war exploded的区别及修改jsp必须重新启动tomcat才能生效的问题


下一篇:数组中的第K个最大元素(java go)