Web Forms vs. ASP.NET MVC

Probably I'm a bit late to the party, but as I gain confidence with ASP.NET MVC I feel I have my cents to share :-) 

ASP.NET MVC is not the anti-Web Forms and Web Forms is not the anti-pattern of ASP.NET development. ASP.NET was created 10+ years ago and in the late 1990s the MS platform was VB-oriented. So it was a natural choice to design ASP.NET as a stateful framework over a stateless medium--the Web. Many of the hot features in ASP.NET (postback, viewstate, forms authentication/authorization, server controls and abstraction over HTML) were eagerly welcomed by the community because they were time-saving facilities just implementing common features that everybody would have aboard.

Over years, MS probably failed drawing Web people attention on architecture and software design. There was an interesting attempt made with the Web Client Software Factory to implement MVP and workflow-based page navigation in Web Forms pages, but that turned out to be too far complex. At least, in my opinion. So in some way instead of driving Web Forms towards a better design it seemed preferable to introduce a new framework on the wave of the success gained by RoR and MonoRail. To many people, ASP.NET MVC looks like the new way to go and the only way to achieve SoC, testability, better design.

For sure, ASP.NET MVC is a "new" ASP.NET designed ten years later looking at the current state of the industry and evolution. Comments on Web Forms vs. ASP.NET MVC are often biased and stuffed with pieces of personal experience that is elevated to the rank of absolute, objectives facts.

The table below lists my top-ten undisputable facts about ASP.NET MVC and Web Forms. These are facts--everything else, I believe, are opinions. And like all opinions they are fully respectable. At the end of the day, Web Forms and ASP.NET MVC is like car or motorcycle and ... it's up to you, your skills, your education, your attitude, and your project requirements.

  1. Web Forms is hard to test
  2. ASP.NET MVC requires you to specify every little bit of HTML
  3. ASP.NET MVC is not the only way to get SoC in ASP.NET
  4. Web Forms allows you to learn as you go
  5. Viewstate is not the evil and can be controlled/disabled
  6. Web Forms was designed to abstract the Web machinery
  7. ASP.NET MVC was designed with testability and DI in mind
  8. ASP.NET MVC takes you towards a better design of the code
  9. ASP.NET MVC is young and lacks today a component model
  10. ASP.NET MVC is not the anti-Web Forms

On this topic, an article on MSDN Magazine is coming out in the July 2009 issue. A Web architecture book is being published these days and I'll start soon on the MS Press big book guide on ASP.NET MVC to be available towards end of the year.

 

Published 11 April 2009 01:03 PM by despos
Filed under: ,

Comments

# ASP.NET MVC Archived Buzz, Page 1 said on 11 April, 2009 08:36 AM

Pingback from  ASP.NET MVC Archived Buzz, Page 1

# Web Forms vs. ASP.NET MVC - .NET Architectonics | Webmaster Tools said on 11 April, 2009 09:37 AM

Pingback from  Web Forms vs. ASP.NET MVC - .NET Architectonics | Webmaster Tools

# Dew Drop - Weekend Edition - April 11-12, 2009 | Alvin Ashcraft's Morning Dew said on 11 April, 2009 10:44 PM

Pingback from  Dew Drop - Weekend Edition - April 11-12, 2009 | Alvin Ashcraft's Morning Dew

# SergeyS said on 12 April, 2009 11:12 AM

You were one of the first to applaud to ASP.NET 2.0 Script Callbacks. (Out-of-band callbacks - you called it, or out-of-bound callbacks according to ScottGu back in 2004, if I remember it correctly)

They wrapped it into MVC paradigm putting down other ways Script Callbacks could be used in. Sad story, great losses.

ASP.NET 2.0 Script Callbacks combined with IE specific Javascript window.execScript() might have generated much better paradigm.

They need to rethink the concept of the procces of dev tools strategic decigion making, in my opinion.

# Tiago said on 13 April, 2009 04:32 AM

Hi.

A year ago you weren't very fond of ASP.NET MVC. Even the testability didn't impress you.

What made you change your mind?

# Summaries 11.04.2009 – 13.04.2009 « Bogdan Brinzarea’s blog said on 14 April, 2009 05:26 AM

Pingback from  Summaries 11.04.2009 – 13.04.2009 « Bogdan Brinzarea’s blog

# despos said on 14 April, 2009 09:38 AM

Correct :) About one year ASP.NET MVC didn't look particularly attractive to me. In general, I don't like the endless sequence of CTPs and intermediate builds through which MS seems to require feedback. Like many others, I'd say, I have no time to waste looking at what MS is doing. I'm happy instead to look at what MS did at least as a Beta. So I seriously started looking at ASP.NET MVC only in November 08, a few days after the Beta 1. I'm still convinced that many people look at ASP.NET MVC because they *feel* they have to in order to write cleaner and better code. Which is not true.  So testing and SoC per se weren't reasons to look at ASP.NET MVC in a so early stage. After Beta I say that I've found an interesting product and a different perspective around ASP.NET.

# Will Steele said on 14 April, 2009 02:58 PM

I am new to the industry and am trying to figure out a direction to take.  Currently I'm working through your ASP.NET 2.0 series for Microsoft and get lost every time some new technology comes out because I don't know the history I'm trying to catch up on yet.  

For someone like me, who's trying to play catch up and find a solid technology at the same time, what would be better to focus on: ASP.NET or MVC?  I want to get into something that won't be out of date by the time I start to get it...and with ASP.NET being a decade old, I can see it starting to get pretty dated already.

# Michael Mitiaguin said on 15 April, 2009 06:57 PM

Has your book been published yet ?  "Microsoft® ASP.NET and AJAX: Architecting Web Applications (PRO-Developer) "  I'd like to see the table of contents.

You may be aware that TOC cannot be seen at Amazon for your previous book "Microsoft® .NET: Architecting Applications for the Enterprise (PRO-Developer) "

# Mark Endless said on 16 April, 2009 03:49 AM

>After Beta I say that I've found an interesting product and a different perspective around ASP.NET.

Translating = a new way to make money as this is the cool thing that the market is asking for, while 1 year ago I was not sure if it was "just a fad" or was going somewhere

# despos said on 16 April, 2009 04:33 AM

Yes, I know about the TOC. I'll be back soon to publish the TOC of both architecture books here. However, details of the ASP.NET MVC are being finalized these days and the book won't be out until late fall. The ASP.NET AJAX book you see on Amazon these days is another book--patterns for AJAX stuff with only a few sections on ASP.NET MVC

# RichardD said on 16 April, 2009 03:24 PM

"ASP.NET was created 10+ years ago"

.NET 1.0 was released in February 2002, so a little over seven years ago:

en.wikipedia.org/.../.NET_Framework

# » ASP.NET MVC book: Chapter 1: Plumbing model community Blog said on 09 May, 2009 10:02 AM

Pingback from  » ASP.NET MVC book: Chapter 1: Plumbing model community Blog

# Emil said on 09 May, 2009 05:11 PM

@Richard

Yes, it was released in 2002, but I assume they worked with it a couple of years ahead.

# elshorbagy said on 13 May, 2009 10:34 AM

I'm a newbie in MVC, but I believe it's a good aspect.

# Dylan Thomas said on 16 May, 2009 09:21 PM

I agree and at this point in time SilverLight is a better fit. You keep the web deployment model while taking advantage of smarter client code where all the cool

UI stuff is not a burden on the web server.

I was just writing about this (reputosupercomputus.blogspot.com/.../asp-net-and-other-things-web.html).

If web is an absolute requierment then MVC looks very encouraging.

# Hardika said on 03 June, 2009 12:58 AM

Hi...

I didnt get the statement "Web Forms allows you to learn as you go"...

can you please explain it....

Thanks,

Hardika Trivedi

# lorenzo battaglia said on 09 July, 2009 09:59 AM

Complimenti. Articolo interessante.

# Renso said on 20 October, 2009 08:08 AM

We are using ASP.Net Mvc for a large scale in house CRM (customer Relationship Management) web-based app. We have about 300 actions scattered across many controllers and testing is very well supported. Since MS is a bit slow with giving us smart controls for Mvc (like GridView, etc) we decided to use the jQuery JavaScript library and supported plug-ins to help with that, for example the jqGrid plug-in that we use for all our lists and their CRUD operations. I personally don't like the fact that the HTML page now contains code again as in the old classic ASP days, but at least you get intellisense with it. I also don't like the fact the the embedded code in the HTML clutters the page, and is not compiled but interpreted at run-time.

I agree you can write well organized code to support SoC but testing is problematic for the UI.

In Mvc styling via external CSS files is great, no more issues with the custom prefixes for HTML tag ids as in ASP.NET.

It is worth mentioning that the examples on the MS site for Mvc are very simple and do not address the design pattern challenges we face for large scale apps. You will need to figure that our for yourself. For example how to handle errors across actions, plugging into another test framework, etc. It is not as simple as you may think and can get complicated. So maybe you don't have to deal with ViewState and the event hierarchy of ASP.NET like On_Load, etc, but now you are going to have to deal with mapping the HTTP request object to your entities, deal with TempData and ViewData as well as the boilerplate code embedded in your HTML pages to suport more complex controls like ListView.

I can honestly say the Mvc is a great approach, although not necessarily the silver bullet, you need to way your requirements.

# Austin said on 22 October, 2009 04:05 PM

Renso, in ASP.NET (regardless of whether you're using web forms or MVC), the embedded code does get compiled, just like the code in the code behind file does. Any change you make to the aspx code will cause a recompile of the application.

So no loss of performance there.

# effects 20th said on 31 October, 2009 06:54 PM

hypothesis vectors human 1960 during windows external shop

Leave a Comment

(required) 
(required) 
(optional)
(required)