Jeroen Bernsen's Blog
A blog about using Microsoft .NET Development Technology

Design Choices: ASP.NET WebForms versus ASP.NET MVC versus Silverlight for Internet Applications

20 October 2009 16:08 by Administrator

Currently there are three Microsoft technologies available for building internet applications:

  1. ASP.NET Webforms
  2. ASP.NET MVC (Model-View-Controller)
  3. Silverlight

The first 2 ASP.NET technologies are serverside and will generate (X)HTML and Javascript.. Silverlight is an application which will be downloaded and will run in your browser.

So if you have to build a new internet application which one is best to use ?

As always it depends on your requirements. First of all I would like to point out that ASP.NET Webforms and ASP.NET MVC are similar technologies for the same problem domain. According to Microsoft ASP.NET MVC is not the successor of ASP.NET WebForms. Both technologies will co-exist for the time being. Not so long ago I attended a brilliant presentation of Scott Guthrie in which he said that WebForms and MVC can be compared as automatic versus manual transmission. In MVC you have to do some more work yourself but you are in complete control. So it’s partly a matter of preference.

In the next section I would like to point out the pro’s and con’s of each technology. I would like to note that some advantages/disadvantes might not apply to each situation.


ASP.NET WebForms


Advantages:

  • HTML/Javascript is encapsulated/abstracted in controls. In theory you don’t have to know much about HTML/Javascript, a large part is done for you. In practise however it’s good to know the inner workings to solve sometimes unexpected results. 
  • ASP.NET webforms is designed to render the correct output depending on the browser used.
  • Large set of (commercial) controls available (grid’s, tabs, etc).

Disadvantages:

  • Only partial control over the rendered output.
  • ViewState can make pages very large.


ASP.NET MVC


Advantages:

  • Complete control over your HTML markup.
  • Routes gives you intuitive website URLs
  • Clear separation of concerns due to MVC pattern, which results in web applications that are easier to maintain and extend over time.
  • Testable by Unit tests.
  • Test Driven Design possible, due to unit tests.
  • Faster Server Side processing.

Disadvantages:

  • Deploying to IIS6 is challenging.


Silverlight


Advantages:

  • Easy design of graphics, animations, and multimedia content.
  • C# and WPF developers can partially use their existing skills. Silverlight contains a subset of the .NET Framework and WPF.
  • Compile time checking of your clientside code (versus javascript)
  • Fast client-side execution.
  • Ability to run out of the browser.

Disadvantages:

  • Installation of clientside plugin necessary. 
  • Does not work on handheld/mobile devices.
  • Microsoft only supports Windows and Mac. Linux is possible with Moonlight but this is not supported by Microsoft.
  • Your Silvlight content does not get indexed by Search Engines.
  • Printing is not supported.
  • Reverse engineering of your clientside code is possible, use something like dotfuscator to prevent this as much as possible.

Furhermore the it’s good to point out that the design/architecture of your application will be completely different using Silverlight since you’ll have to build services to communicate with your backend systems. I would not consider this a disadvantage but it’s just a different way of working and it also means you have to secure these services.

Conclusion

The best technology to use depends on the requirements of your application. Furthermore it’s possible to combine the 3 technologies together in different ways to suite your needs. You can have a site containing ASP.NET WebForms, MVC pages and multiple Silverlight Controls.

Personally I prefer Silverlight for applications (if you can live with the disadvantages) since I think it gives developers the most productivity and results in code that is the easiest to maintain.