ASP.NET MVC v. Web Forms Debate - My View

It seems that the whole world (and Margate) is having its say on which is better - MVC or Web Forms. Scott Guthrie posted his views on technical debates in general, and then contributed his thoughts on MVC v. Web Forms. Ian Cooper has an interesting contribution to make to the debate too. Rob Conery (formerly of Microsoft) posted probably the most linked to opinion on the matter. (There - I've just added another link...) A lot of other blog posts around scream that MVC is better because its better. One even tries to posit the notion that some kind of score card approach can help you decide.

The truth is that I can't tell you which development framework is better for you. But I can tell you which one is potentially worse, and that's Web Forms.

My personal preference is to use MVC for any web development I do, or for which I am responsible. I manage a growing team of web developers, and we do things with MVC. Recently, I went through an exercise in trying to recruit an extra body to the team. I was looking for a mid-level ASP.NET C# developer. I hoped to find candidates who had a good solid understanding of the ASP.NET Web Forms paradigm, ideally with a reasonable understanding of MVC. As the search went on, I found myself continually surprised at the lack of understanding that Web Forms developers displayed in regard to web development in general. One of them admitted to me that they only became aware of Request.Files as a result of reading one of my articles the night before the interview. Most of them had only ever developed web applications with ASP.NET Web Forms.

The fact is that Web Forms is a hugely successful approach to Rapid Application Development, and anyone like me who moved from scripting everything using classic ASP to ASP.NET 2.0 in particular can hardly fail to be impressed the first time they drag a GridView and SqlDataSource control onto a page, select a few options from a design-time configuration wizard, and within a couple of minutes, get a table full of data, with paging, filtering and sorting without writing a line of code. Us oldies remember how long it used to take us to build all of that using VBScript intermixed with HTML. The thing with VBScript (or PHP, for that matter) is that you had to know HTML if you wanted your page to render correctly. You also had to understand what ASP did, and how it differed from Javascript or other client-side technologies. You had to know about Request and Response, GET and POST.

Web Forms does something that MVC doesn't - it hides most, if not all, of that "need to know". And that's why it's potentially worse for you.

Conery describes Web Forms as a lie:

"It’s abstraction wrapped in deception covered in lie sauce presented on a plate full of diversion and sleight of hand. Nothing you do with Webforms has anything to do with the web – you let it do the work for you."

Of course, it doesn't have to be that way. Conery urges you to understand that the web is not stateful and involves things like HTML and HTTP. As his piece progresses, it seems to suggest that you need to learn MVC to be able to grasp this.

You don't.

As a Web Forms developer, there is no reason why you cannot get to grips with HTML, HTTP, CSS, Javascript, browsers, the DOM, the technologies underlying AJAX, the difference between server-side and client-side code and so on, and so on. You should understand why there is only one <form> element in ASP.NET Web Forms, and why you may see multiple forms in other technologies. You should appreciate that the <asp:Label> is the most abused "control" in the entire framework, and why. You should know why the Properties Window in Visual Studio leads you into temptation (unless shortcutting event handlers) and the role that IPostBackDataHandler plays in the scheme of things. And all that is just for starters.

Contrary to Conery, I won't castigate Web Forms or people who develop with them. I've met people who, for whatever reason, have to use Web Forms. Their employers are nowhere near ready or willing to move across to MVC at the moment. And that's not to suggest that moving to MVC is a natural progression in web development either. Many companies have a huge investment in Web Forms technology that they just simply aren't going to throw out - training, third party controls, experience and so on. Many companies don't buy into the whole Unit Test pitch behind MVC. Many companies simply don't test at all.

However, knowing the fundamentals behind web development as a discipline will make you a far better ASP.NET developer. And ultimately more marketable.

And when if the time comes, it will make learning MVC a lot easier, too.

 

Shout it

Date Posted: Monday, February 22, 2010 9:53 PM
Last Updated: Monday, February 22, 2010 10:33 PM
Posted by: Mikesdotnetting
Total Views to date: 49533

12 Comments

Tuesday, February 23, 2010 11:50 AM - Galilyou

This is exactly my own opinion on the matter. Do whatever you want to do, Webforms, MVC, PHP, RoR, etc. The most important thing is to learn about Web Development (HTTP, State, Browsers, Client-Side, etc.) I'm working for a company that is using Webforms, and hell they are not ready to throw it away. We are using tons of third party controls that are just too tedious to configure and get it running. I wish we can move to a better framework soon, MVC is the candidate.

Thursday, May 20, 2010 9:16 PM - Didier

I'd like to argue the points you made but I can't. Really well articulated mike.

Thursday, November 4, 2010 12:39 AM - Alan

I find MVC ideal for mainly static websites and Web Forms for web sites that are applications.

Thursday, March 17, 2011 4:35 AM - Mike Gleason jr Couturier

Amen, its time that web developers begin to know what they are doing. I wish browsers don't display the page at the slightest error found (html/css/js) that would also teach another gang to know their stuff. Web is too permissive so there's not much caring from the developers.

I've also written my point of view on the subject. I'm an architect that desperately want its collegue to move to MVC :)

http://blog.mikecouturier.com/2011/03/aspnet-web-forms-versus-net-mvc.html

Thanks

Wednesday, June 1, 2011 4:33 AM - Sen K Mathew

May I ask you Tech People. Which one is better?. Tell me frankly, so that i can follow that.
I just started learning MVC. Lots and loads of problem before me. I believe one should follow the one which gives you full control. Easy to maintain. I do not believe that splitting things to a hundred folder or hundred file is easily readable and maintainable. Technologies are for making life easier. MVC has folders, folder has different files all are interconnected. Web forms needs some control and bind it there your are.
Sorry to say MVC is little bit difficult in handling. It may be easier for those who write code to display "Helo World" and tell the world that they are big tech and pro. This one is for static site nor for dynamic site. I agree with Allen
I believe in simplycity. Simple to handle at the same time efficient.
Thanks

Friday, June 10, 2011 2:45 PM - Mike

@Sen

You do not need to employ complex architectures for simple sites. Sometimes Web Forms is the best approach. Sometimes MVC will provide more advantages. And sometimes, you can ignore both of those and use ASP.NET Web Pages with razor syntax instead.

The key to this is understanding how each of them work, what their pros and cons are so that you can make the right decision for the right situation.

At least with ASP.NET, you have a choice!

Wednesday, July 11, 2012 1:15 PM - David

I started off as a software developer but always had interests in web development. I moved to the web and Web forms was the best way for me to enter this field and not look like a newbie. Now I'm an MVC/WebPages developer and whenever I look back, I smile at how ignorant I was.

Thursday, September 13, 2012 8:25 AM - Jameel

Mike i am agree with your post. ASP.NET Webforms gives totally abstraction from a web development. If we are starting to develop in ASP.NET MVC we never try to back to ASP.NET Webforms.. I am great fan of ASP.NET MVC..

Friday, December 21, 2012 9:46 PM - milt

Nice article Mike, well put. The end result is to understand the features of both Web forms and MVC not to the finite detail but to a level that can let you choose which one would benefit your project needs and in terms most important to you or your team i.e. development time, usability, maintenance, modularity etc and choose. I started in classic asp 3.0 and VB and Javascript and infusing it into html web apps but I admit I have been babied spoon fed by VStudio .met ide and have even been de-sensitized when controls are dropped and wizards take over so much so that much code is taken for granted and ignored until there is an error... lol... so for me I know it will behoove me to start to learn more about MVC.

Wednesday, January 30, 2013 9:06 PM - John Calvert

Your link to Rob Conery's article is broken, the new correct link is http://wekeroad.com/2009/04/22/i-spose-ill-just-say-it-you-should-learn-mvc.

Saturday, April 27, 2013 2:56 PM - Asim

I prefer ASP.NET Web Pages over both Web Forms and MVC, I think Web Pages does the job for simple and large websites, plus it's easier to understand C# mixed with HTML. I tried MVC and it was good I understood most of it until I got to the data access part! Web Forms is OK to, but I'd prefer if we had an option on the engine. I use Web Forms at work and it does render and hide a lot of the code. What's your view on ASP.NET Web Pages..? You think is good for large websites ?

Tuesday, September 3, 2013 2:18 AM - Marcwolf

Great article. I've been form based programming for many years (vb3,4,5,6) as well as classic ASP programming. I have tried to work with MVC however the tasks needed to get an application up and running (and whilst learning) is quiet a journey.
From my perspective MVC is good as it allow tweekers to have infinitely fine control over the webpage layout.. and Web Forms is good for plain classic data entry style application.
Having developed and used ajax style technology in classic ASP it would be simple to use these skills in a Web Form environment for RAD applications.
Add your comment

If you have any comments to make about this article, please use this form to do so. Make sure that your comment relates specifically to the article above. More general comments can be posted through the form on the Contact page.

Please note, all comments are moderated, and some may not be published. The kind of things that will ensure your comment is deleted without ever seeing the light of day are as follows:

  • Not relevant to the article
  • Gratuitous links to your own site or product
  • Anything abusive or libellous
  • Spam
  • Anything in a language I don't understand including gibberish.

I do not pass email addresses on to spammers, so a valid one will assist me in responding to you personally if required.