public Startup(IConfiguration configuration, IHostingEnvironment env) { Configuration = configuration; var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); this.Configuration = builder.Build(); BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath); }
public Startup(IConfiguration configuration, IWebHostEnvironment env) { Configuration = configuration; var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) // .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true) //.AddJsonFile("appsettings" + "." + env.EnvironmentName + ".json", optional: true, reloadOnChange: true); ; this.Configuration = builder.Build(); BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath); }
/// <summary></summary> /// <param name="configuration"></param> public Startup(IConfiguration configuration) { #region 读取配置文件 var location = System.Reflection.Assembly.GetExecutingAssembly().Location; var applicationExeDirectory = Path.GetDirectoryName(location); var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot _Configuration = builder.Build(); BaseConfigModel.SetBaseConfig(_Configuration); Configuration = configuration; #endregion 读取配置文件 }
public Startup(IHostingEnvironment env) { this._env = env; //Microsoft.Extensions.PlatformAbstractions.ApplicationEnvironment appEnvironment = PlatformServices.Default.Application; //string ContentRootPath = appEnvironment.ApplicationBasePath; //env.ContentRootPath = ContentRootPath; //env.WebRootPath = ContentRootPath; var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); this.Configuration = builder.Build(); var test = Configuration.ToString(); BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath); }
public Startup(IConfiguration configuration, IWebHostEnvironment env) { config = configuration; BaseConfigModel.SetBaseConfig(config, env.ContentRootPath, env.WebRootPath); }