这是默认MVC 3模板中的About.cshtml:
@{
ViewBag.Title = "About Us";
}
<h2>About</h2>
<p>
Put content here.
</p>
我本以为在 About.cshtml
文件中会有一个对 _ViewStart 文件的引用,但显然没有。我查看了
global.asax
和 web.config
,但找不到 About.cshtml
文件是如何与 _ViewStart 文件中的布局相关联的。一切都按预期工作,我只是想知道底层发生了什么...
ViewLocationFormats = ViewLocationFormats.Union(new string[] { "~/Inspinia/ExampleViews/{1}/{0}.cshtml" }).ToArray();
。结果,我不得不将我的_ViewStart.cshtml文件的副本添加到“~/Inspinia/ExampleViews”中,否则它不会被拾取,也不会设置任何布局。 - Triynko