当我创建了我的第一个空的MVC 3项目时,这是/Views/Shared/_Layout.cshtml文件的内容:
我注意到的第一件事是
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>
<body>
@RenderBody()
</body>
</html>
我注意到的第一件事是
<title>@ViewBag.Title</title>
。我不想使用动态的“ViewBag”,而是要使用强类型的ViewModel。
如何更改我的_Layout.cshtml文件,以便主模板使用强类型的ViewModel呢?