Resolved #3740: The virtual file system cannot handle static asset files well.

pull/3850/head
Halil İbrahim Kalkan 5 years ago
parent 9f9607f309
commit 8155027fc2

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Volo.Abp.DependencyInjection;
@ -91,9 +93,27 @@ namespace Volo.Abp.AspNetCore.VirtualFileSystem
protected virtual IFileProvider CreateFileProvider()
{
return new CompositeFileProvider(
var fileProviders = new List<IFileProvider>()
{
new PhysicalFileProvider(_hostingEnvironment.ContentRootPath),
_virtualFileProvider
};
if (_hostingEnvironment.IsDevelopment() &&
_hostingEnvironment.WebRootFileProvider is CompositeFileProvider compositeFileProvider)
{
var staticWebAssetsFileProvider = compositeFileProvider
.FileProviders
.FirstOrDefault(f => f.GetType().Name.Equals("StaticWebAssetsFileProvider"));
if (staticWebAssetsFileProvider != null)
{
fileProviders.Add(staticWebAssetsFileProvider);
}
}
return new CompositeFileProvider(
fileProviders
);
}

Loading…
Cancel
Save