diff --git a/CoreCms.Net.Configuration/AppSettingsHelper.cs b/CoreCms.Net.Configuration/AppSettingsHelper.cs index 4916d5cdc8c605e8558327cf3498f0114b6c6f22..478597ed2c3cd7d5f77c3ea35e3e2251d827b0e3 100644 --- a/CoreCms.Net.Configuration/AppSettingsHelper.cs +++ b/CoreCms.Net.Configuration/AppSettingsHelper.cs @@ -19,10 +19,9 @@ namespace CoreCms.Net.Configuration { static IConfiguration Configuration { get; set; } - public AppSettingsHelper(string contentPath) + public AppSettingsHelper(IConfiguration configuration) { - string Path = "appsettings.json"; - Configuration = new ConfigurationBuilder().SetBasePath(contentPath).Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true }).Build(); + Configuration = configuration; } /// diff --git a/CoreCms.Net.Web.Admin/Program.cs b/CoreCms.Net.Web.Admin/Program.cs index 86a159d6ce0fd6124bdf75e623a278421f691abc..141a6a0eac06f7a09ca87e4e2d87693c747f13fc 100644 --- a/CoreCms.Net.Web.Admin/Program.cs +++ b/CoreCms.Net.Web.Admin/Program.cs @@ -32,7 +32,7 @@ using Yitter.IdGenerator; var builder = WebApplication.CreateBuilder(args); //添加本地路径获取支持 -builder.Services.AddSingleton(new AppSettingsHelper(builder.Environment.ContentRootPath)); +builder.Services.AddSingleton(new AppSettingsHelper(builder.Configuration)); builder.Services.AddSingleton(new LogLockHelper(builder.Environment.ContentRootPath)); //Memory缓存 diff --git a/CoreCms.Net.Web.WebApi/Program.cs b/CoreCms.Net.Web.WebApi/Program.cs index 53556bc7b40d5a5c60f650e539c0663eb87ad456..3572de011b26ea7fbaff37fe831d20c177c876b6 100644 --- a/CoreCms.Net.Web.WebApi/Program.cs +++ b/CoreCms.Net.Web.WebApi/Program.cs @@ -35,7 +35,7 @@ using NLog.Web; var builder = WebApplication.CreateBuilder(args); //添加本地路径获取支持 -builder.Services.AddSingleton(new AppSettingsHelper(builder.Environment.ContentRootPath)); +builder.Services.AddSingleton(new AppSettingsHelper(builder.Configuration)); builder.Services.AddSingleton(new LogLockHelper(builder.Environment.ContentRootPath)); //Memory缓存