ASP. net mvc 3 embraces dynamic types

Source: Internet
Author: User

About a decade ago, Microsoft put all its bets on WebForms and static types. With the continuous development from fragmentation to complete encapsulation, almost every page can be seen as its own program. In the next few years, the industry has been moving towards another direction. The idea that separation is better than encapsulation and late binding is better than early binding is preferred. This leads to two very interesting questions.

The first is the term. Considering the initial Smalltalk MVC pattern, views and controllers are not only tightly coupled, but usually appear in pairs. Most of Microsoft's frameworks are like this, including classic VB, WinForms, WebForms, WPF, and Silverlight. They all use code hidden files to store controller logic. However, currently, "MVC" usually refers to the loose coupling between views and controllers. This is especially true for Web frameworks. The HTML form submission mechanism allows any view to be submitted to any controller. Since this article focuses on Web technologies, we need to use modern definitions.

The second question is: "If you are Microsoft, how can you change the track without causing too much pressure on developers "? So far, the answer to this question is: a new version is released every year until the developer adapts. The first product of ASP. net mvc was released in last March. ASP. net mvc March this year was released in 2.0. 3.0 it is currently in the RC 2 stage and is expected to be officially released in next March.

In December 10, Microsoft released ASP. net mvc 3.0 Release Candidate 2. RC 2 is built on Microsoft's commitment to jQuery: jQuery 1.4.4, jQuery Validation 1.7, and jQuery UI are introduced in the default Project template. Although it is a joke that Microsoft has moved its focus from the server-side controls, the introduction of jQuery UI shows that Microsoft is truly real this time.

For developers who are worried about scalability, there are currently many excellent controls that can replace the session status. With the SessionState attribute, you can tell the Controller whether the session status is read-only, read/write, or completely ignored. This is nothing for a single server site, but if one server needs to obtain the session status from another server, this method can be of great help.

MVC 3 contains the Razor view engine. By default, the engine will encode HTML output, so that we can easily output native text on the screen. Even if there is no risk of HTML injection attacks, unencoded text can easily prevent page rendering.

For many C # developers, what is the most shocking? That is, MVC 3 embraces the dynamic type for controllers and views. The ViewBag attribute exposes a dynamic object. developers can add attributes to the object at runtime. Generally, it is used to send non-mode data from the Controller to the view. The example provided by Scott Guthrie contains the state text (such as the current time) and the entries used to assemble the list box.

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.