/// <summary> /// Core 读取配置文件 /// 1. Microsoft.Extensions.Configuration; /// 2. Microsoft.Extensions.Configuration.Json; /// 3. /// </summary> /// <param name="key"></param> /// <returns></returns> public static string GetConfig(string key) { var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");//配置文件名称 IConfigurationRoot root = builder.Build(); string Valuestr=root.GetSection(key).Value; return Valuestr; }