diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs index 775f7ee704..5057f26ca8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs @@ -16,7 +16,6 @@ using System.Reflection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Razor; -using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure; using Microsoft.AspNetCore.Routing; @@ -28,7 +27,6 @@ using Volo.Abp.AspNetCore.Mvc.Conventions; using Volo.Abp.AspNetCore.Mvc.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.Json; using Volo.Abp.AspNetCore.Mvc.Localization; -using Volo.Abp.AspNetCore.Mvc.ViewFeatures; using Volo.Abp.AspNetCore.VirtualFileSystem; using Volo.Abp.DependencyInjection; using Volo.Abp.Http; @@ -163,15 +161,6 @@ namespace Volo.Abp.AspNetCore.Mvc var application = context.Services.GetSingletonInstance(); partManager.FeatureProviders.Add(new AbpConventionalControllerFeatureProvider(application)); - - //Replace the built-in RazorCompiledItemFeatureProvider in ASP NET Core. - var viewsFeatureProvider = partManager.FeatureProviders.FirstOrDefault(x => x is IApplicationFeatureProvider); - if (viewsFeatureProvider != null) - { - partManager.FeatureProviders.Remove(viewsFeatureProvider); - } - partManager.FeatureProviders.Add(new AbpRazorCompiledItemFeatureProvider(application)); - partManager.ApplicationParts.Add(new AssemblyPart(typeof(AbpAspNetCoreMvcModule).Assembly)); Configure(mvcOptions => diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpRazorCompiledItemFeatureProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpRazorCompiledItemFeatureProvider.cs deleted file mode 100644 index 9e2d527e55..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ViewFeatures/AbpRazorCompiledItemFeatureProvider.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.AspNetCore.Mvc.Razor.Compilation; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.VirtualFileSystem; - -namespace Volo.Abp.AspNetCore.Mvc.ViewFeatures -{ - /// - /// The code for this class comes from - /// https://github.com/dotnet/aspnetcore/blob/master/src/Mvc/Mvc.Razor/src/ApplicationParts/RazorCompiledItemFeatureProvider.cs - /// - public class AbpRazorCompiledItemFeatureProvider : IApplicationFeatureProvider - { - private readonly IAbpApplication _application; - - public AbpRazorCompiledItemFeatureProvider(IAbpApplication application) - { - _application = application; - } - - public void PopulateFeature(IEnumerable parts, ViewsFeature feature) - { - var virtualFileProvider = _application.ServiceProvider - .GetRequiredService(); - - foreach (var provider in parts.OfType()) - { - // Ensure parts do not specify views with differing cases. This is not supported - // at runtime and we should flag at as such for precompiled views. - var duplicates = provider.CompiledItems - .GroupBy(i => i.Identifier, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(g => g.Count() > 1); - - if (duplicates != null) - { - var viewsDifferingInCase = string.Join(Environment.NewLine, duplicates.Select(d => d.Identifier)); - - var message = string.Join( - Environment.NewLine, - "The following precompiled view paths differ only in case, which is not supported:", - viewsDifferingInCase); - throw new InvalidOperationException(message); - } - - foreach (var item in provider.CompiledItems) - { - // Skip pages existing in the virtual file system. This allows us to replace pre-compiled pages. - if (virtualFileProvider.GetFileInfo(item.Identifier).Exists) - { - continue; - } - - var descriptor = new CompiledViewDescriptor(item); - feature.ViewDescriptors.Add(descriptor); - } - } - } - } -}