Asp.net mvc2.0 Series 1-Basic Knowledge

Source: Internet
Author: User

I. Introduction to MVC

Model-View-controller (MVC) may be one of the most common models in the network programming circle in recent years. After Microsoft launched Asp.net MVC. net. on the Net platform, there are not many projects using the MVC Architecture. Most projects still use the webform solution. Of course, it is not difficult to say that the webform solution is here, microsoft has repeatedly stressed that Asp.net MVC is not used to replace webform. Asp.net MVC only provides developers with a new choice. This series hopes to help you quickly understand Asp.net MVC.

1. History

MVC is not a design pattern. It is an architectural pattern used to describe applications.ProgramAnd the responsibilities and interaction methods of each part in the structure. It was first proposed by Trygve reenskaug in 1974 and was a software design model invented by Xerox PARC in 1980s for the program language smalltalk. The purpose of the MVC pattern is to implement a dynamic program design, simplify subsequent modifications and extensions of the program, and make reuse of a part of the program possible. In addition, this mode simplifies the complexity to make the program structure more intuitive. The software system also gives the functions of each basic part through the separation of its basic parts. Currently, the model we use in network development is actually an adapted version of the original model. The crazy popularity of this adapted architecture model is because two extremely popular development frameworks include this model: struts and Ruby on Rails. These two development frameworks are deeply imprinted on the hundreds of frameworks that will be born later. Asp.net MVC is also affected.

2. Responsibilities of MVC at various levels:

The idea behind Model-View-Controller Architecture mode is very simple: Our applications must differentiate the following responsibilities:

Model ):

A model is a data rule and data content applied to data. It generally corresponds to objects to be managed by applications. In a software system, everything can be abstracted into a data model that can be processed in a certain way. What are the users, information, and books in the application? They are just a bunch of data that must be processed according to the corresponding rules (the date cannot be a future date, the email has a specific format, and the name length cannot exceed many characters, etc) the model provides the Controller with a data expression (such as information, books, and album) corresponding to the user request content ). No matter how we present it to users, this data model will not change. This is why we can choose which view to use to display data at will. The model contains the most important components of our application logic, which are applied to the problem we are dealing. The controller contains the internal organizational logic of the application itself (more like a manager ).

View ):

The view provides different ways to display model data. It may be a data filling template. There can be multiple views, and the Controller determines which view to use. A network application usually consists of many controllers, models, and views. A controller can be considered as a master controller that receives all user requests and then calls a specific controller to handle different situations.

Controller ):

The Controller is in charge of user requests (when a user clicks an element on the graphic user interface (GUI) to perform operations, the Controller will receive an http get or POST request ). Its main function is to call and coordinate required resources/objects to execute user requests. Generally, the Controller calls an appropriate model for the task and selects an appropriate view.

3. Call relationship between layers:

Let's take a look at the sequence diagram when users access the MVC Framework site.

Now let's assume that an employee is developing a human affairs system to display the business. First, the Controller collects the condition information submitted by the user, calls the model based on the condition information, and transmits the condition to the business logic layer in the model, the business logic layer obtains the corresponding data from the database based on the conditions, and then returns the data to the model. In the model, the data is encapsulated and then transmitted to the Controller, then, the Controller transmits the corresponding data to the view according to the desired display format, executes the display logic in the view, and finally transmits the view to the user.

Pay attention to the dependencies between MVC layers:

The controller can directly control the view and model, while the view can directly control the model, but the content in the model should not be highly dependent on the view only through weak dependency, for example, some models are designed specifically for some views, but they cannot directly call the view logic in the model. No controller logic can be seen from the model.

Ii. Web form vs ASP. NET MVC

 

III,How to download ASP. net mvc 2

ASP. net mvc 2 is designed to work in vs 2008/. Net 3.5 and vs 2010/. Net 4. Two versions are supported at the same time, which means you can start using them today, instead of waiting to upgrade to vs2010/. Net 4.

Click here to download ASP. net mvc 2 for. Net 3.5 and vs 2008, which can be installed in parallel with ASP. net mvc 1.0 on the same machine.

ASP. net MVC 2 is vs 2010 /. net 4 built-in components, which means that after you install any version of Visual Studio 2010, you do not need to download or install anything else to get ASP. net MVC 2.

Iv. Reference:

Http://www.cnbeta.com/articles/107924.htm

Http://www.cnblogs.com/ywqu/archive/2010/06/21/1762264.html

Http://blog.joycode.com/scottgu/archive/2010/01/17/115853.joy

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.