1.3 new features of ASP. net mvc 3.0/4.0
In addition to relying on. NET Framework 4.0, MVC 3.0/4.0 has made many improvements and introduced many new features. Including:
Razor view engine;
NuGet package management tool;
Improved scalability;
Global Action Filter );
Dynamic Language Support;
Local page output cache;
Improved ajax;
Improved verification mechanism;
Mobile project development template;
Web API;
Next in this section, we will briefly introduce each new feature, which will be further explained later. We will introduce mobile project development templates, Web APIs, and other features only available in MVC 23rd in Chapter 4.0 and Chapter 24.
1.3.1 Razor view Engine
Razor view engine is one of several core components of ASP. NET Web Pages technology. Razor provides a simpler way to mix code and markup language. In ASP. net mvc 1.0 and 2.0, there is only one view engine-WebForm view engine. However, in addition to the Web Form view engine, you can also choose razor view engine to develop applications.
For example, the following code demonstrates how to use the traditional Web Form engine to display the product list on the page.
<% @ PageLanguage = "C #" Inherits = "System. Web. MVC. ViewPage <Product []>" %>
<Ul>
<% Foreach (varproduct in Model) {%>
<Li> <%: product. Name %> </li>
<% }%>
</Ul>
This is very messy. The top page command and the <%> symbol used for switching between code and markup language add many extra characters to the page tag. On the contrary, Razor provides a very simple way to implement the same functions:
@ Model Product []
<Ul>
@ Foreach (var productin Model ){
<Li> @ product. Name </li>
}
</Ul>
As you can see, Razor can switch between code and tag without any starting and ending code tags, so that the page can only focus on the tag displayed on the page, we will use the Razor view engine in Part 1, and Chapter 2 will explain the Razor view engine in depth.
1.3.2 NuGet Package Manager
The NuGet Package Manager is released with ASP. net mvc. NuGet simplifies the management of dependent components. It can directly install required components, library files, and some other toolkit into your project, when you need third-party components, you must manually download them online. Once installed successfully, these components can be easily updated to the latest version in Visual Studio.
You can download the required components and libraries in a large number of online packages through the command line or GUI provided by NuGet. We will detail NuGet in Chapter 14th.
1.3.3 improved scalability
The additional scalability entry points exposed by ASP. net mvc allow you to hook your components to the framework to replace the default functions provided by the framework. Dependency Resolver in MVC can be used to instantiate objects and provide them to the framework. This method can be integrated into different dependency reversal containers, reducing the number of times the object must be manually initialized.
In Chapter 18th, we will learn how to use the dependency parser and dependency inversion container provider's scalability.
1.3.4 global activity Filter
The global activity filter feature in MVC is built on the filters of MVC 1.0 and 2.0 to provide Cross-cutting behavior for all controller activities in the application ). Although this seems to be an inconspicuous feature, it can greatly reduce the number of times the filters are declared in the application. We will go deep into global filters in chapter 16th.
1.3.5 Dynamic Language Support
Because it runs on. NET4.0, ASP. net mvc utilizes some characteristics of DLR, including passing data to the view through a Dynamic Model. We will continue to learn this feature in Chapter 3rd.
1.3.6 page output Cache
Since ASP. net mvc was born, the entire page can be cached within a period of time. Now it also supports caching only specific parts of the page. We will learn about this new caching mechanism in Chapter 17th.
1.3.7 improved ajax
By integrating jQuery and other Javascript libraries, MVC will continue to support a wide range of ajax functions. Json data deserialization is also supported as a parameter for the active method. We will learn about these ajax improvement functions in Chapter 7th.
1.3.8 improved verification mechanism
MVC supports using the data annotation Feature to verify model objects. These features are significantly enhanced in. NET 4.0 and ASP. net mvc. In addition, support for client verification has been greatly improved. We will learn about these verification features in Chapter 6th.
Now you have a general understanding of some notable features of ASP. net mvc. Next we will study these features through a case project. This example will cover part 1 of this book.