Tuesday, June 23, 2009 4:03 PM tony_lombardo

MVC vs. WebForms, A Clear Loser Emerging

Working with WebControls and WebForms for the past 8 years has taught me a lot about web development.  The one thing that I learned above everything is that the onus is on the developer to write good code.  Now that may not sound like something revolutionary, but the fact is that ASP.NET WebForms makes building web applications easy by abstracting away some of the difficulties of a stateless protocol.  And it also makes it easy to forget about what’s actually happening behind the scenes to make everything possible.  Does that mean WebForms is flawed?  No.

MVC offers a fix for some of the problems that WebForms has been plagued with.  Problems like bloated ViewState, and that ‘pesky postback model.’  On the surface, this looks like an attractive solution for every web developer out there.  A promise to get rid of ViewState – a web application’s mortal enemy?  It has to be good. That is until the application your building needs some sort of state mechanism, and you begin re-inventing the wheel.  I think it would have been much easier just to go back to you WebForms application and disable ViewState. 

The problem right now is that there is so much focus over why MVC is better than WebForms, that everyone is forgetting a basic rule of software development: use the right tool for the job.  I’ve said it dozens of times, MVC has a set of scenarios that it first very nicely, as does WebForms.  One platform does not need to be declared a winner – they’re two equals that should be placed into your metaphorical toolbox.  So who is actually losing right now?  The developer community that is caught in the middle of this faux war.  Developers who think that they have to move to MVC out of pride or fear that WebForms will be replaced by MVC.  Developers who are only hearing one side of the story right now at local community events and tradeshows because let’s face it.. WebForms isn’t sexy anymore at 8 years old.  Ironically, this same issue of “sexy talks” was discussed last week at NDC with Scott Hanselman behind the camera.

Conferences aren’t picking talks about “the old stuff”, because they’d rather focus on what’s new.  New is sexier, and conferences are all about attendance numbers.  But here’s what these conferences don’t seem to understand – every day there’s a new developer joining the community who needs to start from zero.  Developers gauge what’s important by what’s being talked about, it’s why we have trends and tag clouds.  It’s human nature.  If I hear 100 people talking about a subject, it must be important.  Right now I hear 100 people talking about MVC, and no one talking about WebForms, so I guess MVC is more important, right?  That’s the type of thinking happening right now, and it’s nothing new.

“MVC brings web development back into ASP.NET”, is one of the most common arguments I hear for its use.  Yet the whole reason for WebForms existence was to free you of the dirty details of building a web application, and let you focus on your business logic.  To give you a set of functionality to be able to build on top of, the same focus for every library and framework out there.  It’s why you don’t have to write browser specific JavaScript when using jQuery or ASP.NET AJAX, and it’s the reason we don’t still program in machine language.  Can I write a tighter loop in assembly than I can in JavaScript?  Sure.  But for the applications I’m writing that’s not going to be an issue.  Maybe I’m writing an application where performance is the top and only concern.  Now writing the application in assembly doesn’t sound like a crazy idea.  If my requirements were to build a spreadsheet like application that offers filtering, copy and paste and exporting to excel, I’m going to jump to WebForms.  That’s the whole point behind using the right tools for the job. 

I read a blog post today that talked about how you should dump WebForms and go with MVC as soon as possible, so you can get back to web development roots.  The argument just didn’t make sense to me.  It’s like asking me to stop coding in C# and move to C++ because C# developers just don’t understand pointers and memory allocation. 

So here’s my call to action.  Rather than talking about why one framework or platform is better than the other, start discussing when one is better than the other.  What scenarios is MVC geared for?  When would you use WebForms (MVP) instead? 

The best advice I’ve seen so far is that WebForms is the platform of choice for building web applications, where MVC is more suited to building web sites.  This is still a bit abstract since there’s no clear definition of web applications, but I think it’s safe to say that if you’re building a web version of a win client application, you’re building a web application.  If you have a ‘grid’ in your page for purposes above that of just layout, you’re building a web application. 

Filed under:

Comments

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, June 23, 2009 5:07 PM by Dave Tigweld

The undeniable fact about webforms were that they were designed to abstract scarey html and javascript away from existing vb6 developers who didn't want to learn web programming.

ASP.Net Ajax was Shoehorned on in order to keep the old dog going and has never felt like it really belongs.  If you already have a command of Html and Javascript then webforms can feel like bloatware that gets in your way.

I believe that a new MS supported framework was needed. I'm not sure MVC is it however.

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, June 23, 2009 5:34 PM by mhildreth

I think you hit the nail on the head. All I hear about is MVC. When developing business applications, I feel like we spend half our time just throwing up a utility that allows somebody to upload, edit, or download data. MVC is totally overkill for those types of things. Also, for those that invest in learning webforms, being able to develop your own toolbox controls can be a huge time-saver in the long term. It doesn't seem to me that MVC promote such componentized code re-use.

While I agree with Dave that ASP.NET Ajax doesn't really feel like it belongs, it is useful, and can make "ajaxing up" an existing application a snap. If you're building static website, then yes, webforms can feel like it gets in the way, but for constantly evolving business applications, I can't see how you could survive without it.

For those who just like to complain about ViewState, I offer the following:

msdn.microsoft.com/.../system.web.ui.sessionpagestatepersister.aspx

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, June 23, 2009 6:36 PM by Sam Mueller

Oh my goodness, where do I start.

Firstly, ASP.NET MVC is, hands-down, better than WebForms for advanced developers.  The WebForms model was great 8 years ago when developers really wanted to develop for the web in the same way they wanted to develop for windows.  Microsoft thought they could abstract away the fundamental differences between the two platforms.  I think they were successful at their goal, and developers were happy.

But, inevitably, web applications got more and more complex.  That's when the cracks started to really show in WebForms.  In order to push the boundaries of web applications, developers needed to get at the guts of everything.  We needed total control.  And the tools needed to help without sacrificing that total control.  The goal of abstracting the web into something it wasn't turned from being an asset to a giant pain in the ass.

To compound on that, AJAX took the web by storm, and ASP.NET WebForms was *NOT* a framework that helped developers during this paradigm shift.  Just think of the first incarnation of ATLAS, especially the UpdatePanel.  Once again, it seemed like microsoft wanted to abstract all the complexity away in exchange for making things easy.  This time developers rejoiced for all of two seconds before realizing what a mess it was to use the Update Panel for anything even remotely interesting (or maintainable).

At some point, the guys at 37Signals created ruby on rails, which built a framework and tools that embraced the web for what it was, and embraced AJAX for what it was going to be.  Their success is the reason why we have ASP.NET MVC, which follows the same methodologies.

So now we have a choice.  And I am the most thankful developer on the planet for that choice.  My career started with .NET 1.0 Beta, and I've always wrestled with WinForms, especially on complex applications.  Since MVC came out, I've been using it and enjoying every minute.  It's like developing without handcuffs.

Sam

# MVC vs. WebForms, A Clear Loser Emerging - Tony Lombardo

Tuesday, June 23, 2009 6:40 PM by DotNetShoutout

Thank you for submitting this cool story - Trackback from DotNetShoutout

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, June 23, 2009 7:05 PM by Carl

@Sam

Well said. Webforms definitely had its purpose, and now that there is a flood of .NET web devs, it's time to graduate away from postback model, among other bandaids in the framework.

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, June 23, 2009 7:33 PM by Craig

I prefer to use MVC, even for Web "Applications" for three reasons.

1. When designing complex UI the Property/Method/Event model that WebForms uses ends up getting in your way. You are forever chasing events and hoping the right thing will get called at the right time to cause some magic to happen like a grid to get formatted or a value to be updated. It was the same problem I had with Delphi after a while. Event Spaghetti is what I call it.

2. For an experienced web developer who knows the difference between a POST and a GET and isn't afraid of writing some JavaScript then MVC is much more productive. It is hard to believe that manually writing HTML for a web page can be done much quicker than using visual tools, but it is the case.

3. The average developer doesn't understand things like trying to separate business logic from presentation logic and database logic. They just started coding and see where it takes them. MVC at least points them in the right direction.

# Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit

Tuesday, June 23, 2009 10:25 PM by Community Blogs

I read a good post today about the silly wars that go on in versus debates, in this case the arguments

# Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit | rapid-DEV.net

Pingback from  Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit | rapid-DEV.net

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 12:45 AM by Steve Sheldon

I generally find it a lot easier to develop applications using MVC.  

Last week I was modifying an existing application which uses the ASP.NET AJAX stuff.  I needed to be able to do a postback from a checkbox in a datagrid to turn the indicated row on or off.

In MVC using jquery, this would have been about 5 minutes work.  Just add the checkbox input with a jquery statement that does a call back to our MVC controller with the appropriate path and inputs.

With ASP.NET AJAX, first I spent about an hour finding out how to do it on google, then I had to write some custom javascript, then I had to make sure I added the ajax httphandler in place and configured pagehandlers.  Took me most of the morning to get it working right and testing the configuration.

And this doesn't even begin to get into the thousands of examples out on the internet using custom ajax functions written for jquery or some other javascript framework that just flat out work out of the box with MVC but require hours of monkeying to make work with the ASP.NET AJAX.  Why not benefit from everything PHP, Ruby or whatever developers do?  Why be different just for the sake of being different?

It's actually the datagrid stuff in asp.net webforms which has caused me the most pain over the years, like my example.  bloody databound events and what not to customize the display.  Bleah!  Just give me a for loop and I'll emit the HTML myself.  Far easier to deal with for non-trivial examples.

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 2:43 AM by shiju

My one year old post on MVC Vs Web Form  weblogs.asp.net/.../asp-net-mvc-vs-asp-net-web-form.aspx

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 3:02 AM by T

100% agree with you, i share same sight to this new model2 wave.

# Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit | Nexo IT - Information Technology News

Pingback from  Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit | Nexo IT - Information Technology News

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 10:16 AM by alessandro

Tony, excellent post. I agree with  you in full 100%.

Thanks for posting this.

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 11:13 AM by docluv

I have not bought into the MVC 'hype', I have seen nothing there to really impress me, yet. Just some new shiney toy to play with. What I have grown tired of is bloated pages generated from Web Controls, etc. So I finally made a concerted effort to put into practice something I wanted to do for several years, create the UI with HTML and CSS. Not using MVC, just using the same ole ASP.NET foundation I created over 300 production sites from the last decade. I just stripped out the web controls and I love it. Face it, if you are going to implement MVC you have to learn these principles in the first place, but sadly MOST MVC zealots are not going to take the time to really do it correctly.

Anyway, you can follow my series as I add new entries: professionalaspnet.com/.../default.aspx

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 11:21 AM by tony_lombardo

@Sam, @Sheldon - Abstraction leads to progress.  That wretched UpdatePanel that you speak of solved a problem that 80% of developers were trying to solve, and did it gracefully.  Admittedly though, it is one of the most overused and abused controls out there.  But to me, WebForms is all about the common (80%) development tasks easier.  By making those tasks easier, developers can focus on the real problem like business logic.  As Sheldon mentioned, for the simpler grid scenario, spitting out HTML is easier, and I agree.  It's when you get to the more complex grids that mimic Excel like functionality that WebForms becomes irreplaceable.  Are there scenarios that MVC makes easier?  Certainly.  The key is to use the tool that fits best, and use it the way it was designed.  

@Craig, thanks for sharing your list of MVC Strengths.  There's no doubt that MVC makes separation of concerns a top priority, and I too grow tired of event spaghetti.  In the end, these are the types of tradeoffs that need to be weighed when choosing between WebForms and MVC, and will likely change from application to application as the requirements change.  As @mhildreth said, for the apps he's building, the MVC separation of concerns is complete overkill.  

Thanks all for your great comments!

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 11:26 AM by tony_lombardo

@docluv - Being a developer who wrote some of that bloated web control markup, I can tell you that I'm entirely with you on the need for clean and concise markup.  The problem has always been the disparity between browsers, and coming up with the least common denominator. Sadly, 7 years ago that meant tables for everything.  The Dark Ages of web development..  Luckily browsers are getting better, and WebControls are being updated.  Hopefully the HTML bloat will be a non issue soon.  I know at Infragistics this is one of our top concerns.

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 11:47 AM by Simone Chiaretta

Tony,

There has been a lot of discussion going on about when to choose one or the other.

WebForm is still great if you have to build heavily datadriven apps, or if need a RAD development, if you are building a prototype, or you have to rely on the component model, either because you need to (a la sharepoint portal, with webparts) or because you deeply invested in control libraries (either custom or 3rd party).

ASP.NET MVC is better if you have a TDD approach, if you want finer control over HTML markup, if you care about writing good code and if you want a more strict guidance for doing it.

Yes, I'd also say that your distinction is fine: if you want to build a web-version of a winform app (a CRM or a ERP) without using Ajax, go for WebForm. If you are building a public facing website, (CMS, e-commerce, government sites, and so on) go for ASP.NET MVC.

In addition to this:

the C# -> C++ vs WebForm -> MVC is not correct.

Now nobody cares about pointers and memory allocations because now PC have loads of memory and because compiler are getting the job better than humans.

The same is not true when it comes to HTML: broadband is not "enough", and unfortunately the "HTML Compiler", which is the WebForm control, is not good enough to replace the human in writing markup... and unfortunately browser are not good enough to render crappy HTML correctly.

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 11:51 AM by Lee Dumond

A closely related post from a few months ago:

leedumond.com/.../10-reasons-asp-net-webforms-still-rock

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 2:30 PM by foobar

-- Simone Chiaretta

unfortunately browser are not good enough to render crappy HTML correctly.

Au contraire.  Browsers, IE in particular, are very, very good at rendering bastardized HTML. This is the single most important reason why web-form lovers believe web forms are the best thing under the sun.  They've never had to worry about bastardized HTML emitted by web-form controls. :-))))))

# I love .NET! » Blog Archive » Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit

Pingback from  I love .NET!  » Blog Archive   » Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 7:31 PM by Simone

@foobar: you are right IE tries to render everything... but unfortunately it renders it in its own way...

given the recent decision of dropping HTML support from Outlook, I guess MS could make webforms emit a Word document... IE9 will probably be Word 2012

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 8:18 PM by alessandro

I'm not aware of one instance in which HTML emitted by the standard webcontrols in asp.net is not XHTML Strict compliant when you set this in web.config <xhtmlConformance mode="Strict"/>

Perhaps you mean it's a little bloated? This is hardly an issue with broadband. Just keep in mind that HTML is HTML regardless.

Further more, if bloated markup becomes a problem, you can easily extend the controls by overriding the rendering. I wouldn't think this to be as easy as editing the html declaratively but the option is there.

In general though, I wouldn't worry about the markup rendered by webcontrols. This is normally fixed and improved with each version of asp.net ; If you recall, asp.net 1.0 emitted non standards compliant markup. This was fixed with asp.net 2.0 and we all got this for "FREE". Everytime there is a problem that demands immediate attention, microsoft has been quick to fix it and these are all fixes we get for FREE again.

Personally, I feel when building web applications, there's a lot more to worry about than an extra "td" here and a nested "table" there.

MVC shines in areas of TDD true and maybe best for some people, but best is subjective and whatever way works for you* is what is *best* in the end.

ASP.NET 4.0 is releasing soon and there are already many new enhancements on the way for webforms : www.asp.net/.../aspnet40 ; Contrary to what many people want to believe, webforms is only getting better. Too many solutions have been built during the past 8 years that will ensure it's *dominance* in the market for many years to come.

Nobody is going to throw out solutions they invested heavily in simply because there is a new model for developing web applications in ASP.NET

As tony points out in this post, MVC gives you choice. It's not here to replace anything and while some may love it, it won't float everyone's boat. Use the tool that fits the job.

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, June 24, 2009 10:29 PM by Bart Czernicki

This is one of those things where I almost got caught up in the hype.  I started researching MVC and it was great, however it also comes with some challenges over web forms that many people who are on the MVC bandwagon don't advertise too much.

For example, one of the biggest challenges for us is maintaining web part integration..something you still need WebForms for (or at least a partial MVC/WebForms split).  I want to see how well this is also supported going forward in enterprise web applications Microsoft offers like SharePoint.

# re: MVC vs. WebForms, A Clear Loser Emerging

Thursday, June 25, 2009 10:00 AM by webforms

cool. These are the same conclusions I came to myself. MVC is nice on paper!

# re: MVC vs. WebForms, A Clear Loser Emerging

Friday, June 26, 2009 6:34 PM by foobar

-- alessandro

>> microsoft has been quick to fix it and these are all fixes we get for FREE

You're deluding yourself.  You pay for AspNet indirectly.  If you want to run your AspNet-based website you have to have Win2k3 or Win2k8. And you must pay for it.

>> many new enhancements on the way for webforms

Again, you're deluding yourself. Microsoft will never abandon its support for web forms, but it's not going to keep sinking any significant money in web forms either. Microsoft is betting on Silverlight. And that's the technology web-form adherents should be looking into.

# re: MVC vs. WebForms, A Clear Loser Emerging

Thursday, July 02, 2009 9:29 AM by G.S.

You said it all!

I only want to comment  on the comment that "WebForms is for VB6 developers who don't want to learn web and Javascript."

That statement falls apart as soon as some "web and JavaScript" guru faces the development of a true business application. He will either fail to deliver, or if he's really good, he'll end up reinventing 99% of what  WebForms brings to the table.

# Faith &#8211; The Time is Now Again &laquo; ActiveEngine

Saturday, July 18, 2009 8:49 AM by Faith – The Time is Now Again « ActiveEngine

Pingback from  Faith &#8211; The Time is Now Again &laquo; ActiveEngine

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, July 22, 2009 11:01 AM by Jay

A very fast search in the article+comments on words like "test", "architecture", "pattern" makes me totally surprised !

All the debate is about comparing two technologies ! But it SHOULD be about comparing two architectural patterns (Page Controller + Template View vs MVC) !!! And, effectively, you choose one of the patterns in different situations !

Why I will certainly not use Webforms anymore is because of the complexity induces by the ASP.NET lifecycle, which is totally unuseful, except for handling stateful components, and the testability of the framework.

Can anyone inject dependencies in pages in a simply manner ? (Yes, I know about Spring ! I've used it !) Can anyone simply unit-test every event handler of a page ? Can anyone simply mock any dependency of a web page ?

So while testability, and so maintanability, is the primary priority, yes, MVC is the best choice you would ever take. But ASP.NET MVC is more than that ! ASP.NET MVC is about scaffolding.

Tony you should really make a deal with one of your friend who knows ruby on rails, and try to beat him in developping a webapp efficiently. Even with complex ASP.NET components. You would be very impressed... unless your friend is not aware of RoR, or if you have blind eyes ! :)

# re: MVC vs. WebForms, A Clear Loser Emerging

Wednesday, August 26, 2009 6:21 PM by Dave

Tony, GREAT article.  Honestly I'm kind of shocked at how quickly some of the webforms zealots have flocked to MVC.

I remember switching from Classic ASP to .Net webforms thinking about how crazy it was to try and break away from the basic GET and POST concepts, and get into the whole postback thing.  Meanwhile people at conventions would hold their nose up and scoff at the old school ASP developers.  Now it almost seems like the old Classic ASP development is back, especially if you compare it to the old COM WebClasses model.

I've made plenty of websites in both MVC and webforms, and I absolutely agree that the two can coexist as tools in the same toolbox.

Just another religious war for the programmers.  Ignore all the shouting and pick for yourself.

# re: MVC vs. WebForms, A Clear Loser Emerging

Monday, August 31, 2009 12:59 PM by Larry

This post is one of the best viewpoints I've seen on ASP MVC and it has helped to solidify it for me. After doing a years worth of Ruby on Rails off and on as well as .NET web forms, I'm convinced that MVC is a better solution for web sites while web forms is an excellent solution for web-based applications. And I define a web-based application like this...

If the solution would work as well in client-server form but web-based is chosen for ease of access and distribution, then it is an application.

(BTW... you don't have to use an MVC solution to do MVC designs.)

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, September 22, 2009 8:05 AM by sura

hello. sir, i am actually working on a thesis entitled "significance of using MVC Framework in developing a web based application"

is you do have some idea on what parameters should i use in order to measure the data retrieval performance of the web application, please please do let me know...

please email me at engotzz_16@yahoo.com

please help me, i am a 4th year computer science student, and i would really like to graduate this school year.. please please help me.. if you can recommend soem other experts on the matter, plwase please tell them just email me.. thnx

# re: MVC vs. WebForms, A Clear Loser Emerging

Tuesday, October 20, 2009 11:50 AM by Mark Arnold

I'm a WebForms Developer and wanted to know about MVC. Ive just watched 10-15 Videos on the subject at http://www.asp.net and was very interested. However, I still can't make up my mind if I should start using it to create a new application I'm developing. There's a lot to think through..will it have the same look and feel?, can I mix them up (webforms and MVC)?, can I use a 3d party control in an MVC page? I've already spent weeks trying to find out the answers whilst not writing a single line of code or dropping a single control onto a page. Do I realy want to be 2 months into development to find I cant do something in MVC that I could in WebForms? If someone can say "Yes, you can" with authority, I'm going to stick to webforms for now

Leave a Comment

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