【发布时间】:2016-03-09 06:31:57
【问题描述】:
我创建了一个新的空 ASP.NET MVC 4 项目,并在 View 和新文件 _Layout.cshtml 中添加了一个新文件夹 Shared 并将此代码放入其中
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>@ViewBag.Title</title>
<script src="@Url.Content("~/Content/style.css")"></script>
</head>
<body>
@RenderBody()
</body>
</html>
现在当我为控制器添加新视图时,它不会自动将其检测为母版页以及Basic Template
@{
ViewBag.Title = "AboutUs";
}
<h2>AboutUs</h2>
在我使用 Layout = "~/Views/Shared/_Layout.cshtml"; 手动设置之前,它不会将 _Layout.cshtml 文件作为母版页
【问题讨论】: