标签: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");
标签:current 常见 baseurl col pre cto conf TBase url
原文地址:https://www.cnblogs.com/ZkbFighting/p/14701518.html