虚拟文件系统和区域

问题描述

我正在尝试在我的 ASP.NET Core ABP 项目中使用区域,如下所示:

Folder Structure

我正在尝试添加这样的单个文件包:

<abp-script src="/Areas/Community/Pages/Mentors/Index.js" />

当我尝试运行页面时,出现以下错误

AbpException: Could not find the bundle file '/Areas/Community/Pages/Mentors/Index.js' from IWebContentFileProvider

文档说这些文件可以位于页面、视图、组件和主题中,但如果它不支持区域,则似乎受到限制。是否需要在某处添加路由以便虚拟文件系统可以找到它?

更新: 我在\Volo.Abp.AspNetCore\Volo\Abp\AspNetCore\VirtualFileSystem\AbpAspNetCoreContentOptions.cs

中找到了源代码

它在哪里设置 AllowedExtraWebContentFolders 列表:

AllowedExtraWebContentFolders = new List<string>
{
    "/Pages","/Views","/Themes","/Components"
};

有什么办法可以添加到这个列表中吗?

解决方法

您可以在模块的 ConfigureServices 方法中对其进行配置。

public override void ConfigureServices(ServiceConfigurationContext context)
{
    Configure<AbpAspNetCoreContentOptions>(options =>
    {
        options.AllowedExtraWebContentFolders.Add("/Areas");
    });
}