My digital scrapbook

ASP.NET WebForms vs MVC

on under Software and Web DevelopmentBe the first to comment

Microsoft give ASP.NET developers choice to develop website or web application. This article comparing both in personal perspective, so it will not so technical article, just a personal opinion.

WebForms has been exist more than a decade and personally has been using it since ASP.NET 1.1. WebForms have strong points and weak points, it’s not perfect thing but many application I was made has been deployed run and can be maintain without much hassle.

Now this is the weak points from WebFroms according to my experience:

  1. WebForms html output is dirty, the html source code filled with hidden input junks in order to mimic state, as you know web is stateless, ViewState taking place to make it possible. It will helps desktop developer migrate / developing web application with ease.
  2. WebForms is easy and sometimes becoming complex when you have challenging requirements. It’s not rare developer pulling their hair when playing with controls. If you have money, you could buy third party controls but there’s also open source controls you could use to help you. When no third party controls fulfill your needs, you can also makes your hand dirty to make your own controls.
  3. Grid manipulation is ridiculously complicated especially when you’re using code behind and merging cells.
  4. It’s slow at first when you’re not compiling your code, everyone know this.
  5. Trust Level, argghhhh.
  6. You need Visual Studio to help you, means you need decent computer.

The strong points:

  1. It’s easy to make application if you don’t make it complicated. Complicated means when you’re using the N layer principle.
  2. It’s faster to finish the job done. ASP.NET template system, Master Pages, will help you to make different layout in no time. ┬áControls/Components will help you on track, everything is event based and have component id.
  3. DataSource property and DataBinding will make your days always sunshine.
  4. You could create membership feature with ease, you just need to tell Visual Studio and generate the membership.
  5. It has been supported for decades.
  6. MVC can’t replace WebForms.
  7. You don’t need to be a ninja.
  8. Suitable for single programmer / small teams with limited time frame.

Now, how about MVC. MVC is not same like Classic ASP. This is different beast. I know I am talking about because I was using ASP Classic several years before migrating to ASP.NET empire.

The advantages using MVC are

  1. Flexible.
  2. Layer separation, Model, View and Controller.
  3. Test Driven Development (TTD) is feasible.
  4. Scaffolding, template generation using Strong Typed Model.
  5. HTML output is as is, what you write in View is what you get. Template is doable.
  6. Clean URL
  7. Maintainable, you could use Areas to organize your application by dividing features as small units.

The weak points already known by me:

  1. Learning curve is quite high, every ninja was a student. You need to understand HTML, CSS, JavaScript and how Web Server works.
  2. You should create everything on your own except automation of course. So, no magical controls like WebForms controls/components.
  3. Strong Typed Model can makes you frustrated when you’re working with dynamic field ex. shopping cart and item details. ViewModel might be needed and then it’s become MVMC (Model View Model Controller) or more common terminology MVVM (Model View ViewModel), maybe in the future will become Service Repository Model View View Model Controller (SRMVVMC) and it will grow depends how sophisticated persons’s brain works.
  4. NuGet can be your tipping point to start disaster.
  5. You can’t pace with time especially when you’re freelance developer and doesn’t have code library.
  6. You need Visual Studio, yeah.

WebForms isn’t better than MVC and vice versa. Both have advantages and disadvantages. For single developer like I am, making simple application using MVC can be fast enough but when making complex application I choose WebForms. I am ignoring the trade off.