ASP.NET MVC 1.0浅析2011-09-15 博客园 Johnhormy为什么要用ASP.NET MVC 1.0?当我刚知道1.0发布的时候,经常这样问。最近正在考虑是否在我们的企业级应用中使用ASP.NET MVC 1.0框架,因此会一直找使用它的理由,希 望大家在关注技术的同时,结合企业应用谈谈自己的看法。1、MVC的组成Models:访问数据库,装载数据、处理业务逻辑。在项目中体现为数据实体类加业务代理类。Views:显示数据,用户界面。在项目中体现为aspx页面,偶尔可以加上code-behind。Controller:按路由规则将请求的数据传送给指定页面,用于显示;也可以把用户输入的数据传递给 逻辑处理类。它可以包含简单的验证逻辑。不应包含数据访问逻辑。2、为何使用MVC提出MVC的目的无非是提高开发效率、提高可测试性。官方的ASP.NET MVC 1.0指南中指出(以下简称指南),基于MVC的Web应用程序有如下优点:[1]对复杂的程序管理更方便It makes it easier to manage complexity by dividing an application into the model, the view, and the ontroller.[2]在开发上有更高的可控性It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.[3]Routing使软件设计有更多灵活性It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure.[4]更加适合测试驱动开发It provides better support for test-driven development (TDD).[5]团队开发项目中有更高的可控性It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior.