3. New Features of ASP. net mvc 3.0/4.0

Source: Internet
Author: User

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 the mobile project development templates, Web APIs, and other MVC-only
4.0 features.

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
In 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 select 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.

Conclusion 1.4

In this chapter, you understand ASP. the history of netmvc shows ASP. the development history of the net platform and Microsoft's core ASP. net: Asp. net web form, Asp. net MVC and ASP.. NET web pages. You have also learned some new features in MVC 3.0 and 4.0. We will introduce these new features throughout this book.

In the next chapter, we will introduce the guestbook project, which will always be the first part of this book as an example. With the help of the example of guestbook, we will start learning ASP. net mvc and gradually deepen it.

Next, we will introduce how to use ASP. net mvc to create a new project.



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.