[ASP. NET MVC2 series] ASP. net mvc introduction to ASP. NET MVC

Source: Internet
Author: User

[ASP. NET MVC2 series]
[ASP. NET MVC2 series] ASP. net mvc tutorial-create a Movie Database Application with ASP. net mvc within 15 minutesProgram"
[ASP. NET MVC2 series] ASP. net mvc introduction to ASP. NET MVC
[ASP. NET MVC2 series] Understand the execution process of MVC applications
[ASP. NET MVC2 series] ASP. net mvc routing Overview
[ASP. NET MVC2 series] How to create custom routing constraints in ASP. NET MVC
[ASP. NET MVC2 series] action requirements and view nature
[ASP. NET MVC2 series] Action filters and custom outputcache actionfilterattribute event occurrence order

 

ASP. net mvc Overview

Measure the test taker's knowledge about the differences between ASP. net mvc applications and ASP. NET web forms applications.

ASP. net mvc Overview (C #)

Model-View-control (MVC) Schema separates an application into three main components: model layer, view layer, and controller. The ASP. net mvc Framework provides another alternative to the ASP. NET web forms mode to create MVC-based Web applications. The ASP. Net MVC Framework is a lightweight framework that integrates with existing ASP. NET features, such as parent page and identity-based authentication. The MVC framework is defined in the system. Web. MVC namespace.

MVC is a standard design model that many developers are familiar. Many types of Web applications will benefit from the MVC framework. Some will continue to use the traditional ASP. NET application mode based on web forms and callback. Other types of Web applications combine these two methods: they are not mutually exclusive.

The MVC framework consists of the following components:

• Model layer. A model object is a part of an application. It implements the data definition logic of the application. Typically, model objects are retrieved and stored in the database's model status. For example, a products object can retrieve information in the database, operate on it, and then update the modified information back to the products table on the SQL server.

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


• View layer. The view layer displays the user interface (UI) of the application. Generally, the User Interface UI is created by model data.


• Control layer. The control layer is used to process user interaction and act on the model layer. Finally, a view is selected to display the displayed user interface. In an MVC application, the view layer view only displays information. The control layer controller processes and responds to user input and interaction. For example, when the control layer processes the query string values and passes these values to the model layer model, the model layer uses these values to query the database in turn.

The MVC mode helps you create an application that separates different aspects of the application (input logic, business logic, and UI logic, it also provides a loose coupling relationship between these elements. This mode specifies the location of each logic in the application. The UI Logic belongs to the view layer. The input Logic belongs to the control layer. The Business Logic belongs to the model layer. When you create an application, this separation can help you handle complex transactions, because it allows you to focus on one aspect of implementation each time. For example, you can focus on the view layer without any business logic.

In addition to managing complex transactions, the MVC mode is easier to test than ASP. NET web applications based on web forms. For example, in an ASP. NET web application based on web forms, a single class is used to display output and respond to user input. To test a single page, you must instantiate this page class. All its child controls and additional dependent classes in the application are targeted at ASP Based on Web forms. NET application write automatic testing may be very complicated. Because there are so many examples to run this page, it may be difficult to write a test for a single part of the application.Code. Therefore, testing ASP. NET web applications based on web forms is more difficult to implement than MVC applications. Moreover, an ASP. NET web application based on web forms requires a web server. The MVC Framework decouples these components and uses a large number of interfaces to enable independent testing of separate parts.
Similarly, the loose coupling between the three main components in the MVC application also promotes parallel development. For example, one developer can develop the view layer, and the other developer can develop the control logic layer. The third developer can focus on the business logic in the model layer.

 

Decide when to create an MVC application
You must carefully consider whether to implement a web application by using the ASP. net mvc framework and any of the ASP. NET web forms models. The MVC Framework replaces the web forms model. You can use any framework for Web applications.
Before you decide whether to adopt the MVC or web forms model for a specific web site, consider the advantages of each method.

Advantages of MVC-based Web Applications
This ASP. net mvc Framework provides the following advantages:

It breaks down applications into model layers, view layers, and control layers to make it easier for us to manage complex transactions.
It does not use view status or server-based forms. This makes the MVC framework very suitable for developers who want to fully control application behavior.
It uses a front controller mode and uses a single controller to process web application requests. This allows you to design an application that supports a wide range of Routing infrastructure. For more information, query the Front Controller on the msdn website.
It provides better TDD support ).
It is suitable for large teams of developers and website designers who require high control over program behavior.

advantages of Web applications based on web forms
the web forms-based framework provides the following advantages:
it supports an event model that maintains the status over HTTP, facilitating the development of Line-of-business web application software. Web applications based on Web Forms provide many events supported by hundreds of server controls.
it uses a page control mode that can add functions to a single page ,. For more information, see page controller on the msdn website.
it uses view status or server-based forms, which makes it easier to manage status information.
it is applicable to small teams where website developers and designers want to use a large number of components to quickly develop applications.
In general, application software development is not that complex, because components (such as page classes and controls) are closely integrated and usually require less code than the MVC model.

Asp. net MVC framework features
Asp. the. net mvc Framework provides the following features:
separated application tasks (input logic, business logic, and UI logic), testability, and default Driving Test Development (TDD ). All the Core Components in the MVC Framework are interface-based and can be tested using simulated objects. simulated objects can simulate the real behavior of objects in actual applications. You do not need to run the control layer in the ASP. Net Process to perform unit tests on the application. This makes unit tests faster and more flexible. You can use any unit test framework compatible with the. NET Framework.
A scalable and pluggable framework. The ASP. net mvc framework components have been designed so that they can be easily replaced or customized. You can insert your own view engine, URL routing policy, serialization of the action-method parameter, and other components. This ASP. net mvc framework also supports the use of dependency injection (DI) and control inversion (IOC) Container models. Di allows you to inject objects into a class, instead of relying on this class to create the object itself. IOC requires that if an object requires another object, the first object should obtain the second object from an external source (such as a configuration file. This makes testing easier.
A powerful URL-mapping component that allows you to build an application with understandable and searchable URLs. URLs do not need to include file extensions. They are designed to support URL naming. This mode works well for Seo and rest addressing.
supports existing ASP. NET functions. ASP. net mvc allows you to use functions, such as table authentication and Windows authentication, URL Authorization, members and roles, output and data caching, session and status management, etc.

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.