MVC or Web Forms? A Dying Question

Thursday, October 29, 2009

Everyone who talks about ASP.NET MVC gets asked the question:

    Should I use MVC or Web Forms?

There’s been quite a bit of debate on this topic, but in a couple years I don’t think it will matter.

10 Types Of Developers

… those who can count in binary, and those who don’t care.

The IT developer who doesn’t read blogs and works 8 hours a day in a Microsoft shop is either portrayed as a hero who produces business value, or vilified as a duct-taping Mortimer who produces a mess. The truth is somewhere in the middle, and the fact is that these developers look at MVC and Web Forms and see this:

twin cars 

… which is why so many people ask the question. There is no clear distinction. Most developers don’t have a passion for TDD or composite UIs – they just want to get the day’s batch transactions through the firewall and into a spreadsheet for the business folks. “I see two web frameworks. I can use either. Just tell me which one is best!!”.

Meanwhile…

Platforms versus Frameworks

There was a big SharePoint conference last week, and SharePoint is clearly positioning itself for global feature domination.

  • Office integration? Check.
  • End user customization? Check.
  • Visual Studio designer? Check.
  • REST and ATOM feeds from anywhere? Check.
  • Administration interface with reporting and logging? Check.Check. Check.
  • Build for Internet and Intranet? Check and check.
  • Connect to any data source? Check.
  • Enterprise level authentication and authorization? Check.
  • Silverlight? Check.
  • Workflows? Check. 
  • Anything else you can think of? Check.

When you stack up SharePoint versus MVC or Web Forms, then everyone can see a contrast. One is a small framework to build on. The other is a giant platform  that moves tons of data across the corporate landscape.

big contrast 

The SharePoint platform is an out-of-the-box-do-everything solution you tweak and augment for a particular environment. Some developers think this is great. Some developers think this is scary. At least the contrast makes for an easy decisions.

There Really Are 10 Types Of Developers

… those who like frameworks, and those who like platforms.

Developers who like platforms will want to use SharePoint. Install it. Customize it. Then watch end users collaborate in spreadsheets on numbers from Analysis Services.

Developers who like frameworks will want to use MVC. It’s light. It’s extensible. It leaves them in complete control.

Web Forms is caught in the middle. The abstraction is too heavy for framework lovers. At the same time, it’s not an out-of-the-box solution despite all the drag-n-drop data controls and pre-configured providers. It’s vulnerable to both sides and both SharePoint and MVC have momentum and excitement.

spectrum 

The question in the next decade won’t be: “MVC or Web Forms?”.

The question will be: “MVC or SharePoint?

But nobody will ask the question, because the answer is easier to figure out.


Comments
gravatar Cyril Gupta Friday, October 30, 2009
The question will be: “MVC or SharePoint?”

-- Scott, are you saying ASP.Net Webforms is moot?
gravatar Marko Friday, October 30, 2009
Interesting post...
Mike Hansen Friday, October 30, 2009
I do not agree with your conclusion.

Web Forms + Ajax is a perfect fit for the many small to medium commercial web applications that we develop whereas sharepoint is either overkill or the client has committed to another cms.

I have no issue with mvc (its "back to the future" using techniques from the asp pre .net days) but i suspect its attractiveness to a lot of developers is that they can avoid the learning curve associated with web forms.
gravatar Arve Systad Friday, October 30, 2009
I disagree. Comparing Web Forms and ASP.NET MVC to Sharepoint just doesn't work. It's like comparing an operating system with a programming language. They are there for two different purposes.

I truly hate Webforms. They give me crappy control of the output code (1998-style HTML), it's difficult to handle once you're doing something that's just plain basic in the framework. And the fact that you must wrap your entire page in a form-tag and always have that viewstate there. It's dreadful if you're into web standards and all that. And I am.
WebForms simply abstracts away too much of what makes web development different from desktop development. You're supposed to know stuff about how to send and get data, how to store data across pages etc. It's just plain messy. In my opinion, WebForms is a true Web 1.0-way of thinking development due to all the silly restrictions all those opportinities give you.


This is what makes ASP.NET MVC so great: You have *complete* control of all output code, it's easy to do testing because you are the one that's always in control of all code (no gridviews or fileupload-controls here!). It's made up the way a web framework is supposed to work, it doesn't abstract away everything with an enormous ViewState to control the flow of your pages.
gravatar Troy Goode Friday, October 30, 2009
I second Arve's opinion about why he prefers MVC. To me it has nothing to do with "avoid[ing] the learning curve associated with web forms" as Mike put it. I used WebForms for many, many years and am so glad to be free of the many hacks that developers that care about standards have to put up with when using it.

More to the point of the article, I completely agree with Scott's take on the matter. In fact I'm already seeing this happening as I hire new employees and consultants - there is already a large swing toward SharePoint development amongst the WebForms community.
Martin Ushima Friday, October 30, 2009
Interesting post...

I'm agree. I think it's time to let go WebForms and focus on MVC. WebForms was thought so the VB6 developers can use the .Net Framework to develop Web apps without to have to learn or get used to a new environment...

But, it's just my opinion.
gravatar Scott Allen Friday, October 30, 2009
@Cyril - I think it's going to get a lot of use, but I also think it's going to lose developers to other web frameworks and platforms. It just doesn't have the momentum anymore.
gravatar Peter Friday, October 30, 2009
I agree that SharePoint is the ultimate platform.

But, developing for it is fundamentally different from MVC and WebForms, so the assumption that people will take whatever they were going to develop in WebForms and now develop that in SharePoint, is too simplistic a statement. Today, if they were to attempt to build what would be a typical WebForms app in SharePoint, they'd probably still have to create a database, because SharePoint's lists have too many limitations. Then, because they aren't using SharePoint's lists, they'd have to create CRUD pages on top of the database tables, and then manually work up validation, business logic (can't use Workflow anymore), and so on...and so they'd be developing a WebForms app inside SharePoint. In the future (SP 2010) maybe enough of the typical LOB app's needs will be covered by the platform, and so developers will be able to use the platform exclusively. Don't know/we'll see.

I guess the point I'm making, is that you embed an assumption above in your dichotomy(? big word alert)--you have developers who like frameworks and developers who like platforms. The assumption is that frameworks and platforms are roughly equally good choices at getting the job done. What I'm saying is that developers who like platforms, in order to solve real problems, have to learn both the platform (SharePoint) and the framework (ASP.NET), and would be better off just learning to be effective with the framework and skipping the platform. There's a small sweet spot where the platform does exactly what you need and saves you time, but I'm going to invoke my very own Pedro's Improved Pareto principle, in which I replace the 80/20 rule with 8/2. 8% of what you need is done with 2% of the effort, the other 92% is left as an exercise for the reader.

I guess this makes me a developer who likes frameworks.
gravatar Burke Holland Friday, October 30, 2009
This is a very interesting post. Let me preface what I am about to say with "I am a SharePoint guy". I also respect your work and your status in the community. I hope this post doesn't sound disrespectful.

I feel like this is one of the most common misconceptions about SharePoint...

"Anything else you can think of? Check."

It is a fallacy to assume that SharePoint is the all encompassing solution that makes standard ASP.NET technologies obsolete. SharePoint is an amazing platform the transcends any standard definition like "Intranet" or "Workflow" or "Business Intelligence". It is all of these things and so much more.

However, as a previous poster pointed out, it is most certainly not an operating system. I don't really think that the words "SharePoint" belong in a comparison between WebForms and MVC.

As to the question of which ASP.NET framework is better, I really think that the fundamental advantage of MVC is the ability to properly do test driven development given the decoupling of the UI from the other layers. WebForms are nearly impossible to test in an automated fashion. I really think that it is high time for Microsoft developers to enter the world of "best practices" when it comes to ASP.NET as a web technology. Whether or not MVC is the proper platfrom is less of a question as simply saying that WeForms is no longer an option as it makes writing flexible and maintainable code very very difficult.

I really really hope this post isn't overly harsh, but I feel like it might be. I know I am going to regret hitting the "Comment" button here in a few seconds.

Thank you for this post. I feel like it has brought out some excellent thoughts on ASP.NET and SharePoint.
Bala Friday, October 30, 2009
Here's the same scale, with different terms:

+-----------+-------------+------------+------------+
Simple Complex Too complex WTF? $$$$$$!!!



terry Friday, October 30, 2009
Myself I am not a fan of MVC at all. It represents a lot of new work and effort on my part for little to no benefit. For the smug developers who are so full of themselves that they must use overcomplicated tools to accomplish simple jobs go ahead and knock yourself out. I'll be finished with my simple small to medium size web site in half the time it takes you to finish your MVC concoction and delivering practical value to the business instead of being a procrastinating code artist.
gravatar Scott Allen Friday, October 30, 2009
@Bala - Good one :)
gravatar Nariman Friday, October 30, 2009
If you're looking that far ahead, you really need to facture in PaaS and IaaS. SharePoint hasn't translated well online yet, but it definitely will one day. Would I, as a career Microsoft developer, be willing to learn a new toolset for the sake of better platform services? Absolutely.
Brad Friday, October 30, 2009
I'm confused. What has sharepoint to do with the mix? Isn't it primarily for intranet purposes?
I think the real question for an MS dev is WebForms vs. MVC vs. Silverlight. If at all possible, I vote for silverlight. Javascript is powerful and all, but I just don't think the cleanness and productivity of having C# everywhere combined with a UI rendering engine that is easy to use and looks the same on all browsers can be beat.
gravatar Scott Allen Friday, October 30, 2009
@Troy - Yes, there is a large shift already.

@Brad - People are already creating Internet sites with SharePoint. In 2010 they explicitly market and license it for use on public facing web sites!
gravatar Nariman Friday, October 30, 2009
@Scott: MOSS has been running public sites for years (marketed and licensed as such). We were at the launch event in 2006 with a high-profile public site. There are some rough edges in its CMS/blogging capabilities that have been refined in 2010. For a sample of public sites running MOSS today (there are more under NDA) see http://www.wssdemo.com/Pages/websites.aspx. In a perfect world, SharePoint would absorb capabilities in Sitecore and Community Server for a well-rounded approach to external sites/communities. 2010 CMS enhancements are catalogued here: sharepoint.microsoft.com/.../Post.aspx?ID=270.

gravatar Ryan Riley Friday, October 30, 2009
@Mike: Really? A learning curve for WebForms? I think the problem is that it is so easy for anyone to do it (poorly). MVC == back to the future asp days? I don't recall many using an MVC pattern in asp, though I'm sure some did. I would think those days were more equatable with a Spaghetti Western. Anyway, thanks for the laugh! :)
gravatar Rob Fearn Friday, October 30, 2009
I believe that anyone who thinks that MVC is a step backwards is not using it correctly! I love it
gravatar John Chen Monday, November 2, 2009
Very insightful.

And you are an excellent writer: you need to write some books.
gravatar Mark Aurit Monday, November 23, 2009
I think you have it backwards. The issue isnt which platform should developers write to. It is why are the $#$@! at MS wasting valuable and limited resources maintaining what are basically 2 code bases that do the same thing. Real smart.
gravatar David Robbins Wednesday, November 25, 2009
Scott, I agree with your assessment but having implemented SharePoint as the platform in our company I can safely say it is one the most limiting environments to craft solutions with. It's is too complex and technical for the business community to interact with in order to accomplish many activities that are easily accomplished in WordPress, Joomla, or MindTouch, etc. You need the technical team to create lists, position web parts and perform layouts so that the business can start using the Wiki or create a home site.

We implemented SharePoint two years ago and we absolutely hate it. The mechanics of configuration are miserable and the html that it emits is a train wreck. Forget adapting any feature in a web part the requires precise alteration of the DOM or html as the improper of tables prevent you from applying selectors effectively. Simple things like rounded corners with CSS is just not possible.

We also fought the dreaded IE 7 error where processing of the DOM would be interrupted and you get the cryptic message box "process interrupted".

It is a shame, as Microsoft could provide something that would be really great, but they have ignored html and css standards with MOSS 2007. If the thought process is that you can empower a team of web developers because of the consolidation of technologies, it fails as the implementation of solutions that are straight forward with Ajax and web services takes far longer in SharePoint.

gravatar Pablo Tuesday, February 2, 2010
I have been reading on MVC and I created some pet projects with it and I am very pleased with the shift from WebForms.

However, I have a bit of a limitation that holds me back with WebForms and I was wondering if you could help me with it.

I work for a Web CMS company as a Consultant, therefore all websites (public sites, intranets, extranets, you name it) are based on the CMS software from my company (which should remain nameless).

One of the features that the sales guys like to pitch about our software is its "friendly" urls. Baiscally all data is stored and structured within the CMS like a file system. Then when you point your browser to http://mywebsite.com/about the CMS will return the contents from the item stored under the root with the name "about".

Each item also has a (interchangeable) template registration which is the physical location of the file that is going to display the contents of it (an .aspx page). Just like the "Views" on MVC.

So, to handle the friendly URLs I have to add a HTTP Handler as follows:
<add verb="*" path="*" type="Cms.ASPDelivery.HttpRequestHandlerFactory, CmsDelivery" />

That will take care of the friendly URLs and will do the mapping between contents and views.

In an architectural way you could see that just like MVC. The data is stored in the CMS, the presentation is independent of the data, and the handler will be the Controller.

But when it comes down to coding in itself, it is the same old Webforms spagetti. Do you see any way that I could use both MVC and my CMS' Http Handler?
gravatar Scott Allen Tuesday, February 2, 2010
@Pablo:

It doesn't sound like you'd be able to rip out the CMS and place your own controller in place, but I'm not clear on the exact architecture of the CMS.

Since the CMS is basically delivering a model to the .aspx page, I'm wondering if you could write your page like an MVC view. That is to avoid code-behind and server controls and use HTML helpers and jQuery instead.
gravatar Pablo Tuesday, February 2, 2010
But isn't the HomeController come in the way of my HttpHandler?
gravatar Scott Allen Tuesday, February 2, 2010
@Pablo - I think you'd have to either use MVC routing or use the HttpHandler - one or the other. If the CMS is smart enough to instantiate any HttpHandler it might smart enough to instantiate the MvcHandler after it does it's work, effectively passing control over to you. On the other hand you might be able to use routing and a special RouteHandler to pass control to the CMS. It's hard to say w/o knowing more about it.
gravatar Peter P Wednesday, March 31, 2010
It does my head in all the people who think you cant acheive SOC, IOC, or testability without asp.mvc framework.

Ever heard of the MVP pattern?
Web Software Factory by MS patterns & practices?
n-tier/n-layer design...

Just because you dont know how to extend and use webforms corrrectly doesnt make it a bad platform.

The only benefit is see of asp.net MVC is if you want more control over mark up.
Which for me i dont care for anymore, after 12 years in the webspace im bored with html, Silverlight is where im moving too.. again making webforms vs MVC a dead argument.
gravatar Jason T Friday, April 2, 2010
I noticed everyone ignored David Robbins' post. his experience is mine as well. I understand that some people have very basic needs and therefore, out-of-the-box Sharepoint works with minor adjustments. However, the reality is, that it is much less flexible than almost every other framework out there. If I could get a hold of Excel Services outside of Sharepoint, I'd never look at Sharepoint again. My development team spent many months creating our own internal web portal applications using Sharepoint as the framework and ended up abandoning it for a simple open source ASP.Net portal. Although lacking a features like a farm architecture is a huge loss, the productivity gain was immense. A good example of MVC versus Web Forms is trying to build a dashboard where the page loads and then each db widget loads AND DISPLAYS independently. In the normal web forms update panel pipeline this requires a huge amount of shenanigans and bs if you even CAN get this to work.
The bottom line is it all depends on your needs.
gravatar Jason T Friday, April 2, 2010
I noticed everyone ignored David Robbins' post. his experience is mine as well. I understand that some people have very basic needs and therefore, out-of-the-box Sharepoint works with minor adjustments. However, the reality is, that it is much less flexible than almost every other framework out there. If I could get a hold of Excel Services outside of Sharepoint, I'd never look at Sharepoint again. My development team spent many months creating our own internal web portal applications using Sharepoint as the framework and ended up abandoning it for a simple open source ASP.Net portal. Although lacking a features like a farm architecture is a huge loss, the productivity gain was immense. A good example of MVC versus Web Forms is trying to build a dashboard where the page loads and then each db widget loads AND DISPLAYS independently. In the normal web forms update panel pipeline this requires a huge amount of shenanigans and bs if you even CAN get this to work.
The bottom line is it all depends on your needs.
gravatar Jiang Monday, July 19, 2010
If I am paid by lines of code I will choose asp.net MVC; if I am paid by number of functins I will stick with Webforms. And if you don't care about making money, then you should just retire and spending your time with your family.
gravatar Eric Monday, September 20, 2010
If MVC is the future, then why is Microsoft continuing to reiterate and re-reiterate that, for the record, Webforms is absolutely not going away?

If MVC truly was the wave of the future, wouldn't it be in Microsoft's best interest to phase out Webforms and get Webform developers up to speed on MVC? And isn't Sharepoint built on Webforms?

As it stands now, it just seems this whole Webforms/MVC/Sharepoint debate is all about religion. Or politics. Change the names to Democrat, Republican and Independent and you've got the same kinds of arguments, with each party not hearing what the other is saying.

IMHO, each advocate of the above has legitimate reasons to support their preferred platform/framework.

gravatar ivan kirachen Tuesday, February 15, 2011
I will be short. I prefer MVC ]:>
gravatar Bartek Saturday, March 5, 2011
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
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!