From cd71dc02932aa81eb7f4d63dcd477f32d79b9107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E4=BF=8A=E5=9F=8E?= Date: Sun, 3 Dec 2023 19:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Asp.NetCore=E7=9A=84Configura?= =?UTF-8?q?tion=E5=AE=9E=E7=8E=B0=EF=BC=8C=E6=9B=B4=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Configuration/AppSettingsHelper.cs | 5 ++--- CoreCms.Net.Web.Admin/Program.cs | 2 +- CoreCms.Net.Web.WebApi/Program.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CoreCms.Net.Configuration/AppSettingsHelper.cs b/CoreCms.Net.Configuration/AppSettingsHelper.cs index 4916d5c..478597e 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 86a159d..141a6a0 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 53556bc..3572de0 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缓存 -- Gitee