我有这两个母版页--Site.Master和Blog.Master 我想知道如何在我的cshtml视图中使用Blog.Master?
的Site.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>
这是我的Post.cshtml,我想使用Blog.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>
答案 0 :(得分:0)
不直接支持使用具有剃刀视图的aspx主服务器,但有一些解决方法。更多信息:http://www.hanselman.com/blog/MixingRazorViewsAndWebFormsMasterPagesWithASPNETMVC3.aspx