ASP.NET MVC vs. Traditional ASP.NET{4}


These days, on average, one in every four websites you come across on your daily browse will be written in ASP.NET, but on the newer and presumably better ASP.NET MVC framework, you may find a meager 1 in 100. So what’s the difference?  What distinguishes one over the other?  Is one a newer version of the other?  I aim to answer all these questions and more in this small commentary.

Internet Framework stats, from http://trends.builtwith.com/framework

Most people with a slight inclination to technology will easily recognize the name ASP.NET.  For those who don’t, what is ASP.NET?  Let’s start with ASP.  ASP, or Active Server Pages, was an early start by Microsoft on the idea of dynamic websites, or websites which, often in conjunction with a database, changed their content without modification to the webpage source.  The implementation was simple enough if one knew HTML: ASP could be directly injected into the code, and all one had to do to make it work was change the page extension to .asp, modify the webserver program to interpret its pages through the ASP interpreter, and voila (as long as you didn’t have syntax errors), magical dynamic webpages.  This was a well-liked and easy to learn language/framework.

However, Microsoft didn’t think it was a versatile enough framework by itself, so they went ahead and phased it out with ASP.NET, which uses the same syntax at its base level, but also provided a fancy new option to generate content using any language in the .NET framework (which is a framework encompassing the high-level or 3rd generation programming languages that Microsoft owns); primarily C# and Visual Basic. This added functionality retained all the functions of ASP while adding in the code-behind features that .NET could offer.

So what is MVC?  MVC, or Model-View-Controller is a methodology in programming of separating the functions of the program under three main categories: the Model, which handles all the backend or server-side stuff like database and filesystem manipulation; the View, which handles the assembly and formatting of the content on the frontend, or the part that the client would see; and the Controller, which receives user input and operates between and orchestrates the Model and View.  Instead of having all their functions and code jumbled into one massive program file, programmers could now, with the MVC method, divide and conquer, which made their programs more organized and therefore easier to debug and eke greater efficiency out of.  It seemed only natural, then, to apply this to website development.

The MVC method was a development on programming standards that became necessary as programs and systems got larger and more complex.  ASP.NET MVC, similarly, is an evolution of ASP.NET toward the same goal.  Making use of the MVC model has inherently addressed a number of concerns that programmers today need to think about, and so these are listed as features specifically of ASP.NET MVC, although they can with a little effort be accomplished without the MVC model.  The most common “features” are Separation of Concerns, Test Driven Development, Search Engine Optimization, RESTful service (Representational State Transfer, a standard that specifies that a service passively responds to client requests only upon request), and general ease of use and ease of integration with other frameworks.

MVC diagram, from http://msdn.microsoft.com/en-us/magazine/cc337884.aspx

It should be noted that this is a discussion on the comparison between MVC and traditional ASP.NET.  ASP.NET in itself contains both this “traditional” flavor, and MVC; so what is traditional?  Simply: ASP.NET Web Forms.

So what are Web Forms?  Microsoft had in the past developed a framework centered on easy generation of Windows graphical user interface.  This was called Windows Forms, and it has been around for a long time, aiding programmers with easy functions for creating GUI.  It has been around almost since the dawn of the .NET framework. Resultingly, many programmers who worked with Microsoft products had become very familiar with Windows Forms, and when Microsoft began developing for web in earnest, they decided it was a good idea to bring those people over easy, so they made ASP.NET Web Forms, which is an almost direct port to a web-based interface of what the programmers had already seen in Windows Forms.  ASP.NET Web Forms became the standard model to use ASP.NET in, because it was easy to teach and easier still to migrate to from Windows GUI development.  So when I say traditional ASP.NET, I mean Web Forms.

The very boiled down version of the distinction between Web Forms and MVC is, aside from the Model-View-Controller aspect, control over the rendered HTML.  Web Forms makes use of some ASP.NET html-like markup to specify and fill, for example, a table.  You more or less tell the code, get me a table and make it this high by this wide and use this database table to populate it, and it does so, but this lets the code decide how many rows and columns and what their widths are etc. etc.  Meanwhile, in ASP.NET without Web Forms, there are only code files entirely populated by a .NET language, and html with small tags in them which are populated by the code in the code files.  This basically allows you to write a html page with ASP.NET placeholders, and then use your preferred .NET language to fill those with output, which you also have full control over.  This is a simple concept, but profound to veterans of Web Forms.

ASP.NET is a big framework that encompasses both MVC, Web Forms, and many other completely different methods of website content generation, as can be demonstrated in the following diagram.

from http://www.hanselman.com/blog/ASPNETAndWebTools20122ReleaseCandidate.aspx

As such, ASP.NET is actually very versatile.  The Web Forms and MVC models both offer their advantages and disadvantages, as do the other methods, depending on the kind of project.  As mentioned by Chris Tavares, a developer at Microsoft, “At this point you may be wondering, “What’s happening to Web Forms? Is MVC replacing it?” The answer is no!”  MVC is a newer methodology than Web Forms, but both of these remain under the wide umbrella of ASP.NET, and while MVC is in many respects better than Web Forms, the improvements are subject to implementation, so both will be around for a while, making website development easier in their respective ways.

References

Framework Usage Statisitics. http://trends.builtwith.com/framework

Sheriff, Paul D. Overview of ASP.NET and Web Forms. http://msdn.microsoft.com/en-us/library/ms973868.aspx

Ritchie, Bryan. Dotnetpowered Language List. http://www.dotnetpowered.com/languages.aspx

Butt, Asad.  Top corporations using ASP.NET for web site development.  http://www.c-sharpcorner.com/blogs/1423/top-corporations-using-asp-net-for-web-site-development.aspx

Rowe, Craig.  Diving Into .NET Web Development.  http://coding.smashingmagazine.com/2012/07/02/dive-net-web-development/

Mcirosoft.  Active Server Pages.  http://msdn.microsoft.com/en-us/library/aa286483.aspx

Esposito, Dino.  Comparing Web Forms and ASP.NET MVC. http://msdn.microsoft.com/en-us/magazine/dd942833.aspx