c# - Razor:使用其他应用程序的布局文件

标签 c# asp.net-mvc visual-studio iis razor

我有一个 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/

相关文章:

c# - 如何将 Type 参数限制为仅某个接口(interface)

c# - 在 mvc 中使用 RedirectToAction() 传递多个对象?

c# - System.Data.SqlClient.SqlException : 'Incorrect syntax near ' `'.'

javascript - 使用 Node.js 访问 azure 表存储

c# - 在 Visual Studio 2010 中为常用代码创建默认设置?

C# 日历约会捕获

c# - 使用 MVVM 构建选项列表

c# - Windows 应用商店应用程序用户界面更新

asp.net-mvc - asp.net mvc 将变量发布到 Controller

javascript - 创建部分 View 以在索引页面中创建新内容