diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index 1bf3e45e4a..f0ca14657b 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -177,6 +177,22 @@ public static class AbpApplicationBuilderExtensions throw new AbpException("The app(IApplicationBuilder) is not an IEndpointRouteBuilder."); } + var environment = endpoints.ServiceProvider.GetRequiredService(); + if (environment.IsDevelopment()) + { + // MapStaticAssets in development mode will have a performance issue if there are many static files. + // https://github.com/dotnet/aspnetcore/issues/59673 + app.UseStaticFiles(); + + // Volo.Abp.AspNetCore.staticwebassets.endpoints.json is an empty file. Just compatible with the return type of MapAbpStaticAssets. + var tempStaticAssetsManifestPath = Path.Combine(AppContext.BaseDirectory, "Volo.Abp.AspNetCore.staticwebassets.endpoints.json"); + if (!File.Exists(tempStaticAssetsManifestPath)) + { + File.WriteAllText(tempStaticAssetsManifestPath, "{\"Version\":1,\"ManifestType\":\"Build\",\"Endpoints\":[]}"); + } + return endpoints.MapStaticAssets(tempStaticAssetsManifestPath); + } + var options = app.ApplicationServices.GetRequiredService>().Value; foreach (var folder in options.AllowedExtraWebContentFolders) {