Introduction to MVC design pattern and installation of ASP. net mvc 3.0

Source: Internet
Author: User

1. Introduction to MVC design patterns

MVC is a widely used design model. MVC is short for Model-View-controller. It is translated into "Model-View-controller" in Chinese ". MVC is a software development architecture model. In MVC model, software systems are divided into three basic parts: model, view, and controller. They are independent and interrelated.

1> MVC design pattern structure

Shows the relationship between the three basic components of the MVC design pattern:

    •  ModelEncapsulates and practices the data and business of the entire software project.
    •  ViewTransmits information to users and collects information submitted by users.
    •  ControllerControls the display logic of the view.

2> advantages of MVC design pattern

I. Ability to correspond to one model with multiple views.

In the context of rapid changes in user requirements, there may be multiple ways to access the application. For example, the Order model may have orders of the system, online orders, or orders of other systems, but the processing of orders is the same, that is, the processing of orders is consistent. According to the MVC design pattern, one order model and multiple views can solve the problem. This reducesCodeThis reduces the amount of code maintenance. Once the model changes, it is easy to maintain.

Ii. Because the data returned by the model does not contain any display format, these models can be directly applied to interfaces.

Iii. Because an application is separated into three layers, sometimes changing one layer can satisfy the application changes. To change the business flow or rules of an application, you only need to change the MVC model layer.

Iv. Facilitates software engineering management. Different layers perform their jobs, and different applications have some same characteristics, which is conducive to management through engineering and tool-based production.ProgramCode.

3> disadvantages of MVC design pattern

I. added the complexity of system structure and implementation.

For a simple interface, strictly abide by MVC. Separating Models, views, and controllers increases the complexity of the structure and may lead to too many update operations to reduce the running efficiency.

Ii. Over-tight connections between views and controllers.

Views and controllers are isolated from each other, but they are closely related. A view does not have a controller and its applications are limited. Vice versa, which hinders independent reuse.

Iii. Inefficient access to model data from views.

Depending on the model operation interface, the view may need to be called multiple times to obtain sufficient display data. Unnecessary frequent access to unchanged data will also damage operation performance.

 

2. Install ASP. net mvc 3.0

The official website of ASP. net mvc is http://www.asp.net/mvc. here we choose to install Visual Web Developer express first, and then install ASP. net mvc 3.0. After visual web developer Express is installed, open and run Microsoft Web platform installer and choose to install ASP. net mvc 3.0.

 

3. Create the first ASP. net mvc 3.0 Project

After ASP. net mvc 3.0 is successfully installed, open Visual Studio 2010 and choose to create an ASP. net mvc 3.0 web application.

Select an Internet Application Template

4. ASP. net mvc 3.0 Application directory structure

After an ASP. net mvc 3.0 Application is created successfully, the program directory structure is as follows:

By default, the directory structure of the MVC application includes the following folders.

    • REFERENCE The namespace and assembly required for running the project.
    • App_data physical storage zone.
    • Content is used to save project content files, such as CSS and images.
    • The controller is used to save the controller. The MVC framework requires that the names of all controllers end with the Controller.
    • Models is used to save the MVC web application model class. This folder usually includes defining objects and the logic code used to define interaction with data. Generally, the actual model object is located in an independent class library.
    • Scripts is used to save the script files used by the application.
    • Views is used to save views. In the views folder, each controller has a folder named with the Controller name prefix.

5. Core namespace of ASP. net mvc 3.0

After you create an ASP. net mvc 3.0 Application, add reference to the project, as shown in:

Namespace related to the core of ASP. net mvc 3.0:

    • System. Web. Routing URL routing provides the URL routing function class in this namespace. It can map a URL route to a controller instead of a physical file.
    • The namespace of system. Web. Extensions ASP. NET Ajax must be referenced when Ajax is used in MVC.
    • The main namespace of system. Web. mvc asp. net mvc. The namespace contains classes and interfaces that support the ASP. net mvc framework used to create web applications. This namespace contains classes that represent controllers, controller factories, operation results, views, some views, and model compilation.
    • System. Web. abstractions The namespace contains some related base classes, such as httpcontextbase and httprequestbase.
    • System. Web. dynamicdata The namespace contains classes that provide core functions for ASP. NET Dynamic Data. In addition, it provides an extension that allows you to customize Dynamic Data behavior.
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.