我有一个 MVC4 Web 应用程序 (1),其下有一个虚拟目录,其中包含另一个独立的 Web 应用程序,如下所示:
MainApp
Areas
SUBAPP <------ THIS is a Virtual Directory with its own Webapp
Views
_Layout_2.cshtml
Views
_Layout_1.cshtml
现在我想从 MAINAPP 管理 SUBAPP 的布局,例如:
_Layout_2.cshtml:
@{
Layout = "../../Views/_Layout_1.cshtml
}
....这给了我错误:
The virtual path '/Views/_Layout_1.cshtml' maps to another application,
which is not allowed
我怎样才能做到这一点???
最佳答案
您是否尝试过将该布局放在/Views/Shared 文件夹中?
也可以尝试使用MEF框架
http://msdn.microsoft.com/it-it/library/hh708870%28v=vs.110%29.aspx
安装起来非常简单,您可以连接来自其他项目和其他解决方案的 View 和 Controller (它就像一个插件)
关于c# - Razor:使用其他应用程序的布局文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16283899/