Question

What's your choice for your next ASP.NET project: Web Forms or MVC?

Let's say that you will start a new ASP.NET web site/application tomorrow. Would you chose Web Forms or MVC, and why?

 45  5652  45
1 Jan 1970

Solution

 84

MVC baby! And JQuery!

Edit: OK, it's fair enough to say my response warrants a little more info.

I'd choose MVC for the following reasons:

  1. I have worked in Rails and found it highly productive. ASP MVC has borrowed so much from Rails that it feels like a direct port in some ways (and that's a good thing in my mind).
  2. AJAX is important, but I hate the Microsoft "Atlas" approach to AJAX (whatever the product name is these days). If you're going to do AJAX, you need to understand the HTML and the JavaScript. Frameworks that hide that from you are hurting you more than they are helping you (IMO).
  3. JQuery has taken over the world it seems in terms of JavaScript frameworks. ASPMVC is well-integrated with it. I want to learn it, so there's great alignment here.
  4. The whole "control" model is a neat idea, but it is more complicated than it appears on the surface. For example, look around on SO for questions about how a UserControl can find its highest level containing control and so forth. The control hierarchy abstraction has leaks in it. Grids are great if they do what you want out of the box, but it's very very hard to customize them to do something they weren't made to do. And the best grid controls on the market (the ones that are highly customizable) are large, bloated, overly complicated beasts. Maybe that shows us that we should drop back down to HTML and let loops in our views do that kind of thing for us.
  5. I believe I can build complete, beautiful apps in ASPMVC much faster than in ASP.Net (and I've got some years of ASP.Net under my belt). Look at StackOverflow ... built quickly on ASPMVC with JQuery, and it's fast, scalable and a joy to use IMO.
  6. Oh, and it's completely open source! It is ok to read the source code, blog about it, and even modify then redistribute it!
2009-04-03

Solution

 21

I would choose MVC simply because it's designed to be testable and mock'able. That would be the major factor in my decision.

WebForms are much more difficult to Unit Test because they're rooted in several concrete classes that are difficult, it at all possible, to Mock. These include HttpContext, HttpResponse, HttpRequest and HttpCookie.

MVC is designed to be testable and it's API greatly facilitates doing so.

Good article on the testability of MVC: http://dotnetslackers.com/articles/aspnet/ASPNETMVCFrameworkPart2.aspx

2009-04-03