简体   繁体   English

ASP.NET MVC 是否已将 Web Forms 制作为旧平台?

[英]Has ASP.NET MVC made Web Forms a Legacy Platform?

Last week at Mix '09, the final version of ASP.NET MVC 1.0 was released.上周在 Mix '09,发布了ASP.NET MVC 1.0 的最终版本。

Some of the stated benefits of this framework are:该框架的一些既定好处是:

  • Clear separation of concerns清晰的关注点分离
  • Testability - support for Test-Driven Development可测试性 - 支持测试驱动开发
  • Fine-grained control over HTML and JavaScript对 HTML 和 JavaScript 的细粒度控制
  • Intuitive URLs直观的 URL

Now, Microsoft are being careful to tout this as being "an alternative, not a replacement, for ASP.NET Web Forms", but given the advantages mentioned above, I'm wondering:现在,微软正在谨慎地将其宣传为“ASP.NET Web 表单的替代品,而不是替代品”,但鉴于上述优势,我想知道:

  1. How long will it be until "classic" ASP.NET Web Forms is considered to be a "legacy" framework?还要多久才能将“经典” ASP.NET Web Forms 视为“传统”框架?
  2. If you were kicking off the development of a new .NET web project today, why would you choose to use Web Forms instead of the ASP.NET MVC offering? If you were kicking off the development of a new .NET web project today, why would you choose to use Web Forms instead of the ASP.NET MVC offering?

Good questions.好问题。 I think ultimately, the answer is going to be the development team's expertise and the project needs that will decide that.我认为最终的答案将是开发团队的专业知识和将决定这一点的项目需求。 ASP.NET web forms is so heavily used that it likely isn't going away anytime soon. ASP.NET web forms 被大量使用,它可能不会很快消失。 Plus, there are so many custom controls and third-party support such as components and books.此外,还有很多自定义控件和第三方支持,例如组件和书籍。 The main benefit of web forms is how easy it is to get a dynamic website up and going. web forms 的主要优点是创建一个动态网站是多么容易。 It really is a RAD way of developing websites.这确实是开发网站的一种 RAD 方式。

However, once that team has more experience with creating larger websites with much higher demands in terms of scalability, reliability, and test-ability, then they will look towards other solutions for that.但是,一旦该团队在创建对可扩展性、可靠性和可测试性有更高要求的大型网站方面拥有更多经验,他们就会为此寻求其他解决方案。 In this case, they will realize that web forms are harder for unit-testing.在这种情况下,他们会意识到 web forms 更难进行单元测试。 They may also see that viewstates reduce performance and look for possible solutions.他们也可能会看到视图状态会降低性能并寻找可能的解决方案。

Although MVC has the stated benefits, it is unlikely that anyone will convert their sites to use this new framework right away or ever.尽管 MVC 具有上述优点,但不太可能有人会立即或永远转换他们的网站以使用这个新框架。 Plus, it requires the team to learn the new technology, and work out the new bugs.另外,它需要团队学习新技术,并解决新的错误。 The team will have to learn new ways to do the exact same thing.团队将不得不学习新的方法来做同样的事情。 For example, how easy is it to support uploading a file using MVC?例如,支持使用 MVC 上传文件有多容易?

As I saw recently, there isn't a reason you can't create a site using MVC and web forms together.正如我最近看到的,没有理由不能同时使用 MVC 和 web forms 创建站点。 So you may see more hybrids in the near future.所以你可能会在不久的将来看到更多的混合动力车。 But I doubt that web forms will ever go away.但我怀疑 web forms 是否会离开 go。

I kind of think about web forms like the way VB1 changed the way Windows applications are created on the desktop.我有点想 web forms 就像 VB1 改变了 Windows 应用程序在桌面上创建的方式一样。 To this day, the RAD way of creating application still exists and will never go away.时至今日,RAD 创建应用程序的方式仍然存在,并且永远不会被 go 淘汰。

Keep in mind that MVC STILL uses WebForms for it's default View Engine.请记住,MVC 仍然使用 WebForms 作为它的默认视图引擎。 Sure, you can replace it with another one, but WebForms is still a core part of it.当然,您可以用另一个替换它,但 WebForms 仍然是它的核心部分。

Also, not everyone prefers to tightly control the HTML or the Routing.此外,并不是每个人都喜欢严格控制 HTML 或路由。 That's not my attitude, but some people just want their job done with the smallest effort.这不是我的态度,但有些人只是希望以最小的努力完成他们的工作。

And aren't.asmx Files technically part of the "old" Model as well?而且 .asmx 文件在技术上不是“旧” Model 的一部分吗? I can say for sure that a lot of people would not like to see them go away.我可以肯定地说,很多人不希望看到他们离开 go。

Still, I personally see ASP.net MVC becoming the main Web Engine for ASP.net in the future, although not in .net 4.0 yet.不过,我个人认为 ASP.net MVC 将来会成为 ASP.net 的主要 Web 引擎,尽管尚未出现在 Z2D509742FECD37062089F 中。

You're asking when a newly-released web platform, ASP.NET MVC, will replace Web Forms, which has been around for seven years. You're asking when a newly-released web platform, ASP.NET MVC, will replace Web Forms, which has been around for seven years.

If we'd been crying out for ASP.NET MVC for the past seven years, then it wouldn't have taken seven years before ASP.NET MVC was released.如果我们在过去的七年里一直在为 ASP.NET MVC 哭泣,那么在 ASP.NET MVC 发布之前不会花七年时间。 The fact is, not everyone sees a need for this.事实是,并不是每个人都认为有必要这样做。 Many of us have been creating complex, highly-scalable web applications for most of those seven years.在这七年的大部分时间里,我们中的许多人一直在创建复杂的、高度可扩展的 web 应用程序。

We even knew how to make them testable, and to separate presentation from business logic and data access.我们甚至知道如何使它们可测试,并将表示与业务逻辑和数据访问分开。 ASP.NET MVC may enforce this separation, but I've done it by using coding standards and code reviews, and by saying, "there's no unit test for that", and "get that business logic out of the UI". ASP.NET MVC 可能会强制执行这种分离,但我已经通过使用编码标准和代码审查来做到这一点,并且说“没有针对此的单元测试”和“从 UI 中获取业务逻辑”。

Also, if I really needed more control of the HTML, I would write my own control to generate the HTML.此外,如果我真的需要对 HTML 进行更多控制,我会编写自己的控件来生成 HTML。

I do not believe WebForms will ever retire.我不相信 WebForms 会退休。

I've been using WebForms at work in business applications and MVC at home for some private things.我一直在业务应用程序中使用 WebForms,在家里使用 MVC 处理一些私人事务。 Though I really like MVC I do not see how this could be possible to implement really complex UI logic with HTML/CSS/JavaScript.虽然我真的很喜欢 MVC,但我看不出这怎么可能用 HTML/CSS/JavaScript 实现真正复杂的 UI 逻辑。 It will quickly become unmanageable and will be quite unsecure since JavaScript can be switched off to prevent disabling some controls or hiding some information.它将很快变得无法管理并且非常不安全,因为可以关闭 JavaScript 以防止禁用某些控件或隐藏某些信息。 On the contrary, turning off JavaScript with WebForms will virtually turn the page dead for any action, either authorized or not.相反,使用 WebForms 关闭 JavaScript 将实际上使页面停止执行任何操作,无论是否授权。

Both platforms will continue to evolve.这两个平台都将继续发展。 For general web sites and HTML/CSS lovers MVC is a way to go, with complex applications you would want object-oriented architecture and artificial event handling even though it abstracts you from the stateless nature of HTTP.对于一般的 web 站点和 HTML/CSS 爱好者,MVC 是 go 的一种方式,对于复杂的应用程序,您可能需要面向对象的体系结构和人工事件处理,即使它使您从 Z293C9EA246FF9985DC6F62A66 的无状态特性中抽象出来。

So, pick up what is best for you.所以,选择最适合你的。

PS Dropping WebForms altogether will jeopardize the future of numerous projects and companies throughout the world. PS 完全放弃 WebForms 将危及全球众多项目和公司的未来。 Microsoft folks would not want to become an object of hatred and the trigger that started the third world war.微软人不想成为仇恨的 object 和引发第三次世界大战的触发器。

WebForms will still have a place for those that want a pseudo-stateless web application that they can easily put together by dragging and dropping.对于那些想要一个伪无状态的 web 应用程序的人来说,WebForms 仍然有一席之地,他们可以通过拖放轻松地将其组合在一起。 For those that don't have to or want to understand how HTTP works.对于那些不需要或不想了解 HTTP 工作原理的人。 It's the ultimate in RAD for web applications.它是 web 应用的终极 RAD。

ASP.NET MVC on the other hands allows much more finer control at the cost of more responsibility.另一方面,ASP.NET MVC 允许以更多责任为代价进行更精细的控制。 You get complete control over your HTML however that means you have to sanitize/encode your output yourself.您可以完全控制您的 HTML 但这意味着您必须自己清理/编码您的 output。 Your application for the most part has to be completely stateless and for some ASP.NET WebForms/Windows WinForms developers that it's a bit hard to wrap their mind around.大多数情况下,您的应用程序必须是完全无状态的,对于一些 ASP.NET WebForms/Windows WinForms 开发人员来说,这有点难以理解。

I don't think either will ever dominate the other though one may be favored.我认为任何一个都不会支配另一个,尽管一个可能会受到青睐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM