Overview of ASP. NET MVC

Source: Internet
Author: User
Overview of ASP. NET MVC

The Model View Controller (MVC) architecture mode consists of three main components: model, view application, and controller. The ASP. net mvc framework provides an alternative mode for creating Web applications using ASP. NET Web forms. ASP. net mvc Framework is a lightweight, highly testable framework, and proposes (with web form applications) and existing ASP. NET functions, such as master page and membership authentication and integration. The MVC framework is defined in the System. Web. Mvc assembly.

MVC design pattern



MVC is a standard design model that many developers are familiar. Some types of Web applications will benefit from the MVC framework. Some people will continue to use the traditional ASP. NET application mode, which is based on Web forms and sending back. Some types of Web applications combine the two methods, and do not exclude other methods.

The MVC framework includes the following:
  • Models: Model. Model objects provide data for the application logic during application implementation. Generally, model objects are used to retrieve and store data in databases. For example, a product object may be retrieved from the information in a database. It operates the product table and then writes the updated information in the SQL Server database and returns it.

In small applications, it is often a model rather than a physical concept separation. For example, if an application reads only one dataset and sends it to the view, the application does not have a physical model layer and related classes. In this case, dataset serves as a model object.

  • Views: View. A view is a display component used for the user interface (UI) of an application ). Generally, this user interface is created through model layer data. Example: a product in the edit product table uses a text box, a drop-down list, and a CheckBox to display the product status.
  • Controllers: Controller. The Controller components process user interaction, work with the model, and finally select a view to display the user interface. In the MVC application, the view only displays information, and the controller is used to process and respond to user input and interaction. For example, the controller processes the queried string values and passes these values to the model layer. These values may be used to query the database.

The MVC pattern helps you create different aspects (input logic, business logic, and UI logic) of an individual application, and provides loose coupling between these elements. This mode specifies the location of each logic in the application. The UI logic belongs in the view. The UI logic is in the View. The input logic is in the controller. The business logic is at the model layer. This separation helps you manage complex applications because it enables you to implement a specific aspect in a centralized manner. For example, you can focus on the View without worrying about the business logic.

The main components of the three loose coupled MVC applications promote parallel development. For example, a developer can focus on the view, and the second developer can focus on the logic on the controller, while the third developer can focus on the business logic in the model.

Support Test-driven development

 

In addition to management complexity, the MVC mode is easier to test than ASP. NET Web applications. For example, in an ASP. NET Web application of a Web form, a class is used to display both output and response user input. Compile a Web form, ASP. NET application automation testing can be very complicated, because to test individual web pages, you must instantiate the page class, all its child controls, and apply for additional dependent classes. When so many classes are instantiated to run pages, it is difficult to write and test each part of the application. Therefore, testing an ASP. NET application is more difficult than testing and executing an MVC application. In addition, components decoupled from the MVC framework can be tested out of the rest of the framework due to a large number of interfaces.

When creating an MVC application, you must carefully consider whether to implement an ASP. NET Web form or Web application model using the ASP. net mvc framework. The MVC Framework does not replace the Web form model. You can use the Web application framework. (If you have existing Web forms applications, they will work as well as before .)

When developing a website using any framework, consider the advantages of each method:

Advantages of MVC-based Web Applications

The ASP. net mvc Framework provides the following advantages:

  • It can more easily reduce the complexity of applications, divided into Models, View, and controller.
  • It does not use view status or server-based Forms. This makes the MVC framework an ideal choice for programmers who want to completely control the behavior of an application. It uses a front-end controller mode to control Web application requests through this single process. This allows you to design an application that supports a wide range of Routing.
  • It provides better test-driven development (TDD) support.
  • It operates well on a network that is highly supported by large team developers and web designers who need control of an application's 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.