Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET MVC 3嵌套母版页-如何在cshtml视图中使用它?_Asp.net_Asp.net Mvc 3_Master Pages - Fatal编程技术网

ASP.NET MVC 3嵌套母版页-如何在cshtml视图中使用它?

ASP.NET MVC 3嵌套母版页-如何在cshtml视图中使用它?,asp.net,asp.net-mvc-3,master-pages,Asp.net,Asp.net Mvc 3,Master Pages,我有这两个母版页-Site.master和Blog.master 我想知道如何在cshtml视图中使用Blog.Master 网站主: <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> <!DOCTYPE html> <html> <head runat="server"> <title> <asp:ContentPlaceHo

我有这两个母版页-Site.master和Blog.master 我想知道如何在cshtml视图中使用Blog.Master

网站主:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
   <title>
     <asp:ContentPlaceHolder ID="phPageTitle" runat="server" />
   </title>
</head>
<body>
   <div>
      <div style="clear:both">
            <asp:ContentPlaceHolder ID="phAppMenu" runat="server">
            </asp:ContentPlaceHolder>
         </div>         
      </div>

      <div style="clear:both;min-height:500px">
         <asp:ContentPlaceHolder ID="phContent" runat="server">       
         </asp:ContentPlaceHolder>
      </div>

      <div style="clear:both">
         <asp:ContentPlaceHolder ID="phFooter" runat="server">       
         </asp:ContentPlaceHolder>
      </div>
   </div>
</body>
</html>

这里是blog.master:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/Shared/Masters/Site.Master" %>
   <asp:ContentPlaceHolder ID="iphPageTitle" ContentPlaceHolderID="phPageTitle" runat="server">
      This is the page title
   </asp:ContentPlaceHolder>

   <asp:ContentPlaceHolder ID="iphTopMenu" ContentPlaceHolderID="phTopMenu" runat="server">
      Home | Browse | Search | Post | New | Featured | Recommended
   </asp:ContentPlaceHolder>

   <asp:ContentPlaceHolder ID="iphContent" ContentPlaceHolderID="phContent" runat="server">
      Main Content goes here
   </asp:ContentPlaceHolder>

   <asp:ContentPlaceHolder ID="iphFooter" ContentPlaceHolderID="phFooter" runat="server">
      This is the footer
   </asp:ContentPlaceHolder>

这是页面标题
主页|浏览|搜索|发布|新|特色|推荐
主要内容在这里
这是页脚
这是我想使用Blog的Post.cshtml。Master:

@model MyApp.Models.ShowPostViewModel
@{
    ViewBag.Title = Model.Post.Title;
}
<section>
    <article>        
        <div style="overflow:hidden">
            <div style="overflow:hidden">
               <header>
                  <b>@Model.Post.Title</b><br />
                  Author: @Model.Post.Author | Id: @Model.Post._id
               </header>
               @Html.Raw(Model.Post.Content)               
               </div>
            </div>
    </article>
</section>
@model MyApp.Models.ShowPostViewModel
@{
ViewBag.Title=Model.Post.Title;
}
@Model.Post.Title
作者:@Model.Post.Author | Id:@Model.Post.\u Id @Html.Raw(Model.Post.Content)
不直接支持使用带有razor视图的aspx主机,但有一些解决方法。更多信息请点击此处: