【发布时间】:2012-01-09 12:51:53
【问题描述】:
我在 Visual Studio 2010 Prosessional(在 ASP.NET MVC 3 项目中)中发现了一件奇怪的事情。如果我有下面这样的语法,编译器不会检查里面是否有任何错误。
<% foreach (var item in Model) { %>
<div class="author-box">
<div class="author-box-header">
<%: Html.ActionLink(item.Name, "", new { id = item.AuthorID }) %>
</div>
<div class="author-box-body">
Books: <%: Html.DisplayFor(o => item.Books.Count) %>
// Here's the error, shoutld be item.Book.Count
</div>
</div>
<% } %>
只有当我在解决方案中自己打开那个 .aspx 页面时,编译器才会验证代码。
那么,如何强制编译器自动检查语法 在编译项目时?
【问题讨论】:
标签: visual-studio-2010 asp.net-mvc-3