ASP.Net MVC VS ASP.Net形式

ASP.Net MVC VS ASP.Net形式

问题描述:

为什么你会考虑使用ASP.Net MVC或标准ASP.Net与窗体和控件的Web项目?除了个人preference会是什么原因呢?你找到更适合MVC什么样的项目和正常的ASP.Net哪些项目?

Why would you consider using ASP.Net MVC or standard ASP.Net with forms and controls for a web project? Apart from personal preference what would be the reasons? What sort of projects do you find more suitable for MVC and what projects for normal ASP.Net?

你会考虑你当前的项目转移到一个或另一个?

Would you consider transferring your current projects to one or another?

的WebForms是其中隐藏从显影剂卷材的力学的抽象。它可以让桌面开发他们的技能相对容易地转移到网上。虽然它在某种程度上实现这一目标,在实际情况下,通常不长抽象休息之前和一个人摆在凌乱的解决方法。单元测试是困难的,因为用于处理用户交互逻辑紧密与UI耦合的。由一个典型的WebForms应用产生的HTML是远非最佳。这是典型的臃肿,难以阅读,并包含了很多内容是present只允许抽象的工作,例如,视图状态,这是信息的巨大BLOB帮助抽象给国家的假象给开发商,尽管网络是一个无状态的网上平台。

WebForms is an abstraction which hides the mechanics of the web from the developer. It allows desktop developers to relatively easily transfer their skills to the web. Whilst it does achieve this in part, in practical scenarios it is usually not long before the abstraction breaks and one has to put in messy workarounds. Unit testing is difficult, because the logic for handling user interactions is tightly coupled with the UI. The HTML produced by a typical WebForms app is far from optimal. It is typically bloated, difficult to read and contains a lot of content which is present only to allow the abstraction to work, e.g. viewstate, which is a huge blob of information to help the abstraction give the illusion of state to the developer, even though the web is a stateless medium.

MVC中,然而,涵盖幅材的力学。这发生在Web请求和响应的基本操作是psented给开发者简单的抽象$ P $。 MVC有一个清晰的关注分离。该模型简单地重新presents与该系统有关的业务对象或实体,与用于检索和存储这些对象的实例的方法。控制器采取网络请求,对模型进行操作,然后手中的模型视图。视图是一个纯粹的渲染器,用于presenting模型给用户,并暴露界面项,允许用户制定下一个请求传递给控制器​​。这种关注点的分离允许相对容易的单元测试。开发人员完全控制生成的HTML和没有必要对其他文物是present(例如视图状态)。

MVC, however, embraces the mechanics of the web. The fundamental operations which take place in a web request and response are presented to the developer as simple abstractions. MVC has a clear separation of concerns. The model simply represents the business objects or entities with which the system is concerned, with methods for retrieving and storing instances of these objects. The controller take a web request, performs operations against the model, and then hands the model to the view. The view is purely a renderer, for presenting the model to the user and exposing interface items which allow the user to formulate the next request to pass to a controller. This separation of concerns allows for relatively easy unit testing. The developer has complete control over the HTML produced and there is no need for other artifacts to be present (e.g. viewstate).

我preFER MVC。对于罕见的情况下,可能要使用Web表单有用的,例如快速原型或演示,但除此之外,我总是建议使用MVC的。

I prefer MVC. For rare occasions it may be useful to use Webforms, e.g. a quick prototype or demo, but otherwise I would always recommend the use of MVC.

作为一个项目从Web表单到MVC转让,这显然是非常主观的,依赖于应用本身,而预算限制,但总的来说,我相信这是正确的方向迈出的一步。

As for transferring a project from Webforms to MVC, this is obviously very subjective and dependent on the application itself, and budgetary constraints, but in general I believe this is a step in the right direction.