When to use ASP.NET MVC vs. ASP.NET Web Forms?

17,430

Solution 1

You don't choose ASP.Net MVC over ASP.Net, because ASP.Net MVC still is ASP.Net. You do choose ASP.Net MVC or ASP.Net Web Forms, and there are lots of good reasons to do that:

  • Easier to get control over your HTML
  • Easier to do unit testing
  • Few "Gotchas"

On the other hand, Web Forms do have a few points in their favor:

  • Easy to put simple CRUD/business apps together extremely fast
  • Hard to beat ViewState performance in local LAN environment
  • Easy to learn forms paradigm

The result is that if you're building business apps in a corporate LAN environment (which honestly is still most web developers), Web Forms is really great. In that sense Microsoft really knows their market. But if you're building an app for the public internet, you might want MVC so you can test thoroughly and be sure your pages aren't bloated with unnecessary ViewState or JavaScript data.

Additionally, something that has changed over the last several years is that even many corporate intranet applications now need to support home/remote use, making MVC more attractive to that crowd than it had been.

Solution 2

Use MVC if all your team members are skilled enough to manage "control over HTML", otherwise your code will turn into a tag soup.

In other words

bool useMvc = true;
foreach (TeamMember member in team.Members)
{
    useMvc = useMvc && member.IsSkilled;
} 

Solution 3

http://weblogs.asp.net/shijuvarghese/archive/2008/07/09/asp-net-mvc-vs-asp-net-web-form.aspx

check that blog !

Bottom line "separation of concerns"

Solution 4

I'll give you a couple purposes, with clear advantages.

  • If your purpose is a public facing website that will be banking on traffic, use MVC. It is optimal for search engine optimization.

  • If your purpose is an enterprise web-application that acts like a desktop app, I would lean towards web forms, since state management and compartmentalization of your resources into underlying server controls offers huge advantages if used correctly.

Solution 5

The biggest problems facing developers is managing complexity and keeping code "clean". MVC gives the developer the reins to leverage OOP to tuck away complexity and make code easy on the eyes.

Webforms will be faster to develop in the short term, but it doesn't lend itself to long term sustainability in terms of maintenance and growth.

Share:
17,430
xsx
Author by

xsx

Updated on June 26, 2022

Comments

  • xsx
    xsx almost 2 years

    One of the common questions asked regarding ASP.NET MVC is why should you use it over ASP.NET Web Forms? The answer generally includes ViewState and clean URLs, amongst others. Towards the end you'll find a blurb about using the right tool for the job and that they serve different purposes. However, I don't believe I've ever seen what those purposes are. So, when would you actually choose ASP.NET MVC over ASP.NET Web Forms, or ASP.NET Web Forms over ASP.NET MVC?

  • Matt
    Matt almost 15 years
    I'm curious about your statement about "hard to beat viewstate performance in local LAN environment" - can you clarify? Are you suggesting it's network burden is less when local so you don't have to worry about network performance as much?
  • Steven Sudit
    Steven Sudit almost 15 years
    Viewstates can get very large, and this is definitely a performance issue when the server is not local.
  • Joel Coehoorn
    Joel Coehoorn almost 15 years
    The absolute network burden is the same: a 60K viewstate is 60K everywhere. The relative network burden is very differetn: 60K to a local network is nothing, but 60K uploaded for every postback over even a consumer broadband connection can make your pages appear much slower than they are.
  • Joel Coehoorn
    Joel Coehoorn almost 15 years
    Also, if your viewstate is absolutely HUGE, you're doing something wrong.
  • Kivus
    Kivus almost 15 years
    Whether or not the site will be easily recognized by search engines is something that is frequently left out of design considerations. Good point on it being an MVC benefit.
  • Steve Horn
    Steve Horn over 14 years
    Take issue with "Easy to learn forms paradigm". (Compare request/response with the forms page lifecycle.) Also: Webforms leaves little control to the developer to manage complexity.
  • JTech
    JTech over 11 years
    Search engine optimization should no longer be a deciding factor in the MVC vs WebForms debate. ASP.NET 4.0 now allows you to also use the URL Routing engine to map URLs to ASP.NET Web Forms pages as well as ASP.NET MVC Controllers. See this link for details