ASP.NET MVC vs. Web Forms

The July edition of MSDN mag has an interesting article by Dino Esposito that compares Web Forms And ASP.NET MVC. The author presents an excellent 100 feet view of ASP.NET MVC and I loved reading it. As I'm going to re-read it & recommend it to others, I've made a Reader's Digest version of it that squeezes the 3500+ worded article to about 500 words -

Benefits of ASP.NET Web Forms
  • ..stable and mature, supported by heaps of third party controls and tools.
  • To simulate stateful programming over the Web, ASP.NET Web Forms introduced features such as viewstate, postbacks, and an overall event-driven paradigm.
  • ..componentization of some ASP best practices
  • Productivity and rapid development of data-driven, line-of-business applications
Drawbacks of Web Forms
  • ..separation of concerns (SoC) has not been a natural fit with the Web Forms paradigm.
  • Automated testing of an ASP.NET Web Forms application is hard
  • ..postback model .. makes it harder for search engines to rank ASP.NET pages high.
  • ..excessively large viewstate is problematic

Benefits of ASP.NET MVC
  • ASP.NET MVC is a completely new framework for building ASP.NET applications, designed from the ground up with SoC and testability in mind....a working environment that enables, not penalizes, test-driven development (TDD)
  • No postbacks
  • No viewstate
  • ..stateless behavior, full control over every single bit of HTML, total script and CSS freedom.
  • ..leaner run-time stack ... the run-time stack of ASP.NET MVC is simpler and the difference is due to the lack of a page lifecycle.
  • unparalleled level of extensibility
Drawbacks of ASP.NET MVC
  • ..full control over HTML, JavaScript, and CSS, ASP.NET MVC means that you enter the Web elements manually....a step backward in terms of usability and productivity.
  • ..not something you can easily learn by experimenting....this may be the source of decreased productivity for the average Web Forms developer.
Interesting facts
  • ..the size of the viewstate decreased significantly in the transition from ASP.NET 1.1 to ASP.NET 2.0 when Microsoft introduced a much more efficient serialization algorithm.
  • Ruby-on-Rails has proved that MVC can also be a successful pattern for Web applications; and ASP.NET MVC confirms this.
  • ASP.NET MVC today lacks some level of abstraction for creating standard pieces of HTML. HTML helpers are just an interesting attempt to speed up HTML creation
  • Web Forms embraces the RAD philosophy whereas ASP.NET MVC is TDD-oriented
  • Web Forms goes toward an abstraction of the Web that simulates a stateful environment, while ASP.NET MVC leverages the natural statelessness of the Web and guides you towards building applications that are loosely coupled and inherently testable, search-engine friendly, and with full control of HTML.
  • ASP.NET MVC is not the only way to get SoC in ASP.NET.
  • Web Forms was designed to abstract the Web machinery.
  • ASP.NET MVC exposes Web architecture.
  • ASP.NET MVC was designed with testability and Dependency Injection in mind.
  • ASP.NET MVC takes you towards a better design of the code.
  • ASP.NET MVC is young and lacks a component model.
  • ASP.NET MVC is not anti-Web Forms.
  • Web Forms is a model based on the "Page Controller" pattern.
  • ASP.NET Web Forms doesn't prevent unit testing, but it requires much discipline and repetitive boilerplate coding to do so.
  • ..in ASP.NET MVC intrinsic objects are mockable as they expose interface and base classes.
  • ..control over HTML and SEO-friendly URLs, both advantages of ASP.NET MVC, can be achieved to some extent in Web Forms. ASP.NET 3.5 SP1, in particular, includes the URL Routing and History API for SEO

Also see:
ASP.NET MVC: What is it and should I use it?
Biggest advantage to using ASP.Net MVC vs web forms

Comments

  1. In my opinion, the question is becoming blurred with a lot of the cool features of MVC making their way into Webforms. ASP.NET 4.0 added URL Routing, reduced ViewState, and greater control of the HTML mark-up produced by many ASP.NET controls, now the next version of Webforms will incorporate many more MVC features into Webforms. http://bit.ly/dNhBd8

    ReplyDelete

Post a Comment