Contact

Technology

Oct 27, 2011

ASP.NET MVC vs. Web Forms – Part 1: The Advantages of MVC

Thiago Silva

Thiago Silva

Default image background

This is part 1 of a 3-part series comparing ASP.NET MVC and Web Forms as a paradigm for ASP.NET websites.  The purpose of this series is not to choose one technology versus the other, but rather to point out each of their strong points and equip the reader with enough information to make the appropriate decision when selecting which tool to use for their next web application project.

I recently presented on this topic at the Dallas Techfest and was very surprised by two things: (1) the increased interest in MVC, and (2) the number of people who have no plans to adopt MVC for new web application projects at their jobs and client engagements.

While those two points are juxtaposing, they indicate that a lot of people, simply put, just don’t know the advantages of the MVC pattern and how to sell those to the business owners and the rest of their team, in order to get buy in.  This post will provide you with some major pointers to help in making the case for ASP.NET MVC.

MVC is a mature design pattern, dating back to 1979 from the Xerox PARC.  It conveys the idea that your presentation should be ignorant of your business and domain logic – in other words, it enforces separation of concerns.  In the MVC world, web requests are received and “dispatched” by the “controller” which is in charge of communicating with the business logic to retrieve data and then to pass this data, the “model”, to the presentation layer, the “view”.

Integrate applications across the enterprise for improved data integrity and consistent processes

Explore Our Microsoft Consulting Services  →

What does this buy us, might you ask? Well, it fosters the adoption of best practices and good software development patterns, such as:

  • Separation of Concerns

  • Unit Test/TDD and Type Mocking

  • Loosely coupled tiers

  • Highly maintainable code

  • Better code organization

  • S.O.L.I.D.

The ASP.NET MVC framework is built on top of a mature web stack and, thus, provides the developer with all the goodness that comes with ASP.NET, such as Session State, Caching, Profiles, Security and Membership, Master pages, Localization, Configuration, Health Monitoring, Tracing, and more.

When opting to develop your applications with MVC, you are not throwing away years of investment into a platform, but rather increasing the ability to write BETTER code.

It’s true that MVC forces the developer to rethink their strategy for handling web requests by ditching Viewstate and Postbacks, but it also embraces the web for what it is: a stateless protocol.  It doesn’t try to shield the developer from that truth by introducing complex event lifecycles and bloated response payloads.  Furthermore, it makes it much easier to adopt newer client and browser scripting frameworks, such as jQuery, while giving the developer full control of their mark up.

Additionally, as a side effect of having full control of your markup, you have better opportunities to do search engine optimization (SEO).  Most search engines use a combination of criteria to rank pages.  Web pages that yield better, lighter, semantic HTML markup have a better chance to rank higher in search results.

If you are planning a mobile strategy for your web content, look no further.  ASP.NET MVC makes it rather simple to adopt HTML5 compliant web sites, and will not corner you into non-semantic, server control generated markup.  With MVC, you can more easily leverage new CSS3 constructs, as well JavaScript libraries such as Modernizr, to provide progressive enhancement and graceful degradation of web content.  This is great news when planning for a website that should render well in many types of connected devices, including tablets and mobile phones.

While MVC has many advantages, one must consider the learning curve required when jumping in from Web Forms.  There’s a significant amount of knowledge to be gained by the web developer in order to fully understand this paradigm in ASP.NET.  Web Forms developers have spent most of the last decade writing code to handle postbacks, and relying on viewstate to make some magic happen with their web pages.  It’s hard to throw all of that out the window, and get closer to the metal.  Let’s face it – Web Forms made it easy to create new web application! Debating whether MVC is better than Web Forms is likely a pointless debate, and is best left to the web zealots.

The next installments in this series will take a closer look at Web Forms, and how it has evolved in order to play well with the newer web stack, including support for HTML5, CSS3, JavaScript and AJAX libraries.  We’ll also provide a feature comparison between the two, and hopefully you can make your case for the appropriate technology when creating your next web application.

Conversation Icon

Contact Us

Ready to achieve your vision? We're here to help.

We'd love to start a conversation. Fill out the form and we'll connect you with the right person.

Searching for a new career?

View job openings