ASP .NET MVC Framework简介

An Introduction to ASP .NET MVC Framework
ASP.NET MVC Framework 简介

According to Scott Guthrie at Microsoft, "MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers.
 依照微软ScottG Guthrie 的表述,"MVC 是一个用来将一个程序的实现分为三个部分(模型、视图、和控制器)的框架。

  • "Models" in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL).

            在一个MVC构架的应用程序里,模型负责维护状态。 通常情况下,这个状态被保存在数据库中(例如:我们可能通过一个Product类来再现保存在SQL数据库内Products表中的数据。

  • "Views" in a MVC based application are the components responsible for displaying the application's user interface. Typically this UI is created off of the model data (for example: we might create an Product "Edit" view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).

            "视图"在一个MVC构架的应用里负责展示整个应用的用户界面。Typically this UI is created off of the model data (例如:我们依照一个Product对象的状态创建一个由文本框、下拉框和复选框组成的视图)

  • "Controllers" in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction.

            控制器在一个MVC构架的应用里负责处理用户交互,操纵模型并且最终选择一个视图将结果呈现给用户。在一个MVC程序中视图仅负责呈现信息-处理和相应用户的输入和交互是控制器的职责。

One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application. Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.

The MVC pattern can also help enable red/green test driven development (TDD) - where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself."

This tutorial covers an introduction to the MVC pattern using Visual Basic. It shows you want software is needed to work with the model. It also includes a brief overview of the URL routing assumptions that are a foundation to the implementation of the pattern. Finally, a sample application is created to demonstrate the fundamentals of this new web-application model.


Useful MVC Sites
ASP.NET 3.5 Extensions Preview
ASP.NET Model View Controller Applications
Scott Guthrie's Blog on MVC
Video Links
An Overview of the MVC Pattern
Setting up the MVC Preview Environment
URL Routing
Setting up New Pages
MVC Controller Actions
Creating HTML in Views
MVC - Putting it all together
posted @ 2008-04-18 09:30  riordan  阅读(1239)  评论(0编辑  收藏  举报