Net Core 读取json文件

2021-05-29 21:02

阅读:523

标签:current   常见   baseurl   col   pre   cto   conf   TBase   url   

一种是网上常见的一种

  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文件

标签:current   常见   baseurl   col   pre   cto   conf   TBase   url   

原文地址:https://www.cnblogs.com/ZkbFighting/p/14701518.html


评论


亲,登录后才可以留言!