Silverlight & ASP.NET MVC vs Web Forms (Very High Level)
Silverlight 2 RTW has been out for a couple of weeks now and it is already being compared to ASP.NET MVC which is an evolutionary way to design web applications using ASP.NET. I read a concise summary (pros and cons) of ASP.NET MVC from Jason Young. His article can be read here: http://www.ytechie.com/2008/10/aspnet-mvc-pros-and-cons.html
I decided to compare Silverlight in a similar way to what Jason did when he compared ASP.NET MVC vs. Web Forms.
Here are the items he listed as ASP.NET MVC vs. Web Form:
PROs vs. ASP.NET Web Forms
- No ViewState or "surprise crap"
- This applies to Silverlight as well. Silverlight brings the "desktop" experience to the end user and there is no ViewState that is used in Silverlight.
- Faster server-side & client-side
- Silverlight is faster on the client/server side depending on how you look at it. Silverlight is compiled in a .NET subsystem of Silverlight. You have access to multithreading, LINQ, complex data structures, etc. The performance vs. an ASP.NET or AJAX/JavaScript application is it magnitudes times better because of the client execution and some of the items that normally are handled in a server BLL can be brought down to the client
- Simplified model for multiple related views
- Silverlight supports the complete seperation of the data and the UI. Taking this further by just creating seperate views for say another consumer of Silverlight is pretty powerful. You can apply the same MVC/MVP pattern inside Silverlight and attain this level of abstraction. Jason mentions an example of being able to create a seperate view for an iPhone and only the View component has to change. This applies to Silverlight as well for different things. For example, I have large sized Silverlight app I want to port to SharePoint. I can create a "Smaller View" for SharePoint so it fits nicer into the UI. Furthermore, Silverlight Mobile is being private tested now. I would assume that same very powerful level of abstraction applies as well to create a "Mobile view" for your Silverlight application.
- Unit Testable
-
Challenges if you are not running IIS 7
-
Client Caching
CONs vs. ASP.NET Web Forms
-
Difficult to convert existing code
-
Silverlight is a completely different programming platform than either ASP.NET WebForms or MVC. Not only will a lot of the code not convert, you also have to think about the client layer and in most cases a complete re-architecture is needed if you are replacing large modules inside your existing ASP.NET site.
-
NOT the best SEO out of the box
-
Data access
-
Security
-
Silverlight runs on the client. A lot of your bits are then roaming in the wild on the internet. Furthermore, some of the data access techniques do not support full WS* standard security. Therefore, beyond certificate based transport security, you are either writing a lot of your own plumbing code or waiting for the next rev. The XAML code is pretty much insecure; not many applications have their Intellectual Property in their UI. In Silverlight, that can be very easily reverse engineered using
Silverlight Spy for example. Silverlight, just by nature, is a little less secure than an ASP.NET MVC application. Obviously, you would want to encrypt/obfuscate your Silverlight assemblies before letting them off in the wild.
In conclusion, even though Silverlight and ASP.NET MVC are two completely different technologies, they share A LOT of the same pros and cons Jason pointed out vs. Web Forms. The only difference is that the hosting model for Silverlight is a lot simpler. Silverlight does have its nuances with data access and security that you have to worry about. Furthermore, you do get other benefits like client-side performance and client-caching.