【问题标题】:Razor: use Layout file of other ApplicationRazor:使用其他应用程序的布局文件
【发布时间】:2013-04-29 16:41:51
【问题描述】:

我有一个 MVC4 Webapp (1),它下面有一个虚拟目录,其中包含另一个独立的 Webapp,如下所示:

 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

我怎么能做到这一点???

【问题讨论】:

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


【解决方案1】:

您是否尝试将该布局放在 /Views/Shared 文件夹中?

你也可以尝试使用MEF框架

http://msdn.microsoft.com/it-it/library/hh708870%28v=vs.110%29.aspx

安装起来真的很简单,你可以连接其他项目的视图和控制器,也可以连接其他解决方案(就像一个插件)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 2019-09-06
    • 2013-07-02
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多