MVC 3 and 4 come with many improvements and several new features in addition to
the new dependency on .NET 4.
These new features include:
■ The Razor view engine
■ Package management with NuGet
■ Improved extensibility
■ Global action filters
■ Dynamic language features
■ Partial page output caching
■ Ajax improvements
■ Enhancements to the validation infrastructure
■ Mobile templates
■ Web API
1. The Razor view engine
This engine provides a concise way to mix code and markup within the same file.
classic code:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Product[]>" %>
<ul>
<% foreach(var product in Model) { %>
<li><%: product.Name %></li>
<% } %>
</ul>
<ul>
<% foreach(var product in Model) { %>
<li><%: product.Name %></li>
<% } %>
</ul>
razor code:
@model Product[]
<ul>
@foreach(var product in Model) {
<li>@product.Name</li>
}
</ul>
<ul>
@foreach(var product in Model) {
<li>@product.Name</li>
}
</ul>