几年来一直在使用 ASP.NET 和 MVC,但之前从未见过这个......
刚收到一台新机器。创建了一个新的 MVC4 Web 项目(用于 Internet,在向导中)。我正在使用“开箱即用”的项目来测试一切是否正确设置和配置。
如果我使用内置的 Web 服务器从 Visual Studio (2010) 运行它,那么一切都很好。但是,我在 IIS 中设置了一个应用程序,它没有呈现布局(默认生成的代码位于 ~/Views/Shared/_Layout.cshtml 的默认位置),但我确实得到了 Index.cshtml(~/Views/Home/Index.cshtml)。 cshtml) 内容。布局中没有呈现任何内容:没有 html 标记、没有样式、没有 javascript、没有 body 标记,什么都没有。
是否进行了基本诊断... IIS 中没有出现服务器错误。事件/应用程序日志中没有任何错误记录。Chrome 网络检查器工具中没有显示任何内容(甚至没有 404s 或 500s)。
有任何想法吗?我被难住了……感觉它的东西非常非常简单。
Index.cshtml(默认生成的代码,除了我在底部的测试代码,只是为了确保 MVC dll 被正确提取):
<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>
<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>
<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>
@foreach(var i in new int[]{1,2,3,4,5})
{
<div>Test @i.ToString()</div>
}
在 Chrome 中渲染:
<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>
<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>
<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>
<div>Test 1</div>
<div>Test 2</div>
<div>Test 3</div>
<div>Test 4</div>
<div>Test 5</div>