. Net MVC Framework and. netMVC framework

Source: Internet
Author: User

. Net MVC Framework and. netMVC framework
Overview

MVC is an idea. There are many frameworks based on this idea, such as Struts in java. What is this idea?

MVC ideas

An idea is an idea. To know what this idea is, you need to first know what it is because of. You need to know that there is no hate for no reason, the idea cannot be generated without any reason. So what triggered the idea and pushed it to the climax?

To understand this, first of all, we need to analyze the status of our Web programming world before the arrival of MVC. At that time, Web development was mainly developed in the WebForm development mode, that is, the event-driven page of asp.net. This development mode tightly coupled to the data and display data, the change of the two has a significant impact on the other party.

For example, drag and drop a server-side control on the front-end page, and the background Code directly operates on the control. In this case, if our requirement is that the control does not need to be displayed, what we need to do is to remove this control, find the code to operate the control in the background, and then remove it.

After reading this example, it may not sound very profound. At this time, you can enlarge it to make its logic more complex, such: the background Code contains many events of this server-side control. In each event, many other server-side controls (Attribute Modification and call methods) are operated ), it also has a corresponding impact on the foreground (return js script to modify the style, etc.). In this way, you need to remove this control, which is equivalent to turning the page over the day. Of course, this is just a page, what if there are multiple such pages? This is likely to re-develop our UI Layer.

The MVC idea is to completely decouple the data provider (Control) and the data display Party (View), that is, to divide our previous asp.net page into two independent blocks: block A and block B, the bridge between Block A and block B is data. A gives data to B, B loves how that data can be used to show that data, without affecting A, that is, in the MVC Framework, server-side controls in asp.net cannot be used.

Two MVC frameworks

When using MVC, we often hear that there are two methods to build a framework using MVC. One is that MVC is only an architecture of the UI Layer, one is that VC is the UI Layer, and M is all the layers below (the specific number of layers below depends on how you build the project). I prefer the first one, that is, MVC is just a realization layer framework. Why do you think so? As mentioned above, the communication between V and C is that the media is data, and the data is M. From here we can know that C transmits a M to V, the attributes in M should contain all the data to be displayed in V. From this point of view, M is actually FormModel (PageModel), which has no semi-gross relationship with the entity layer in the three-tier architecture.

Conventions are greater than configuration ideas

In. net MVC Framework implementation, there is an important idea that the Convention is greater than the configuration, we know that when we use MVC to develop the Web, the user requests all the methods in C, and then, in C, the method returns the corresponding entity (possibly other things, binary streams, etc.) to a V. At this time, interesting things come, that is, to the V, where should I implement this? Put it in the configuration file, or write it in the program, Microsoft wrote it in the program, java Struts is the configuration file (this has no experiment ).

The configuration file is more flexible. However, if you think about a method in C, I have to write one in the configuration file, which is a bit cold; the idea written by Microsoft in a program is that the Convention is greater than the configuration. That is, when the method in C creates V, the system automatically creates a folder (with the same name as C ), the view Convention of V is that it has the same name as the method name. At the same time, when the method has no corresponding V, the system will automatically find the folder with the same name as C, the view with the same name as the method name is displayed. Of course, this Convention is not dead. You can also create a view by writing some method parameters.

Summary

In learning. net MVC, I was shocked too much, those encapsulated js Code, jquery library, validation (front and back-end), asynchronous (implicit non-implicit), HttpHelper, routing rules, and so on, the extraction is too good, and the encapsulation is great.


NET controls can be used in the MVC Framework of. NET?

Since the mvc framework is used to separate the Three Layers
The web form server controls are tightly coupled with the logic layer for ease of use.
This is fundamentally against the mvc philosophy.

The MVC Architecture of. NET is completely different from that of web form, so it cannot be used.

For the net MVC Framework

At present, there are basically no Chinese materials. They are all in English. I would like to find such materials.

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.