1
我创建了一个新的空ASP.NET MVC 4项目,并在View
和新文件_Layout.cshtml
增加了一个新的文件夹Shared
,并把这个代码到ASP.NET MVC:共享布局
<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.cshtml
文件作为母版页,直到我是手动设置与Layout = "~/Views/Shared/_Layout.cshtml";