From 544e24d85fc2d0f5da987f1a2607323ec4fb7a84 Mon Sep 17 00:00:00 2001 From: maliming Date: Sat, 7 Sep 2024 13:19:34 +0800 Subject: [PATCH] Skip check libs if `WebRootPath` is not set. --- .../Volo/Abp/AspNetCore/Mvc/Libs/AbpMvcLibsService.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Libs/AbpMvcLibsService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Libs/AbpMvcLibsService.cs index 1d122549342..b59cbefa45c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Libs/AbpMvcLibsService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Libs/AbpMvcLibsService.cs @@ -74,7 +74,14 @@ protected virtual Task CheckLibsAsync(HttpContext httpContext) var logger = httpContext.RequestServices.GetRequiredService>(); try { - var fileProvider = new PhysicalFileProvider(httpContext.RequestServices.GetRequiredService().WebRootPath); + var webHostEnvironment = httpContext.RequestServices.GetRequiredService(); + if (webHostEnvironment.WebRootPath.IsNullOrWhiteSpace()) + { + logger.LogWarning("The 'WebRootPath' is not set! The 'CheckLibs' feature is disabled!"); + return Task.FromResult(true); + } + + var fileProvider = new PhysicalFileProvider(webHostEnvironment.WebRootPath); var libsFolder = fileProvider.GetDirectoryContents("/libs"); if (!libsFolder.Exists || !libsFolder.Any()) {