razor 类库 - 库中的视图不用于主机中的控制器

问题描述 投票:0回答:1

主机应用程序是 ASP.NET Core MVC。主机应用程序具有

SampleController
Index
操作。
Index
操作在宿主项目中没有
View
文件。

结构:

- Host application
├── Controllers
│   └── SampleController
└── Views
    └── Sample

我的项目中的 Razor 类库作为插件工作。它们在主机应用程序启动时动态加载。例如

SamplePlugin
项目有
Views/Sample/Index.cshtml

结构:

- Razor class library (SamplePlugin)
└── Views
    └── Sample
        └── Index.cshtml

如果我在 SamplePlugin 中定义默认情况下工作的控制器。但是我想避免在插件之间复制重复的控制器。

目标:由于第三方可以有很多实现,我在主机中有使用接口服务的控制器。 Razor 类库应包含特定服务的视图文件和接口实现。

编辑:基于 https://github.com/dotnet/aspnetcore/issues/38373#issuecomment-1449717787 解决方案是从

Content
 中删除 
.csproj

asp.net-core razor razor-class-library
1个回答
0
投票

csproj 中存在错误,会突然从编译中删除视图(在插件项目内)

解决方案是遵循 https://github.com/dotnet/aspnetcore/issues/38373#issuecomment-1449717787 的指南

Content
文件中删除
.csproj

© www.soinside.com 2019 - 2024. All rights reserved.