This is the final installment of a three-part series comparing ASP.NET MVC and Web Forms as a paradigm for ASP.NET websites. If you missed the first or second parts of the series, you can find part one here and part two here. 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.
If you have read parts one and two of this blog series, you should be more comfortable putting MVC and Web Forms head-to-head to answer the burning question: “Which technology should I use for my project?” Let’s walk through some considerations when choosing the appropriate technology for any web project and discuss how MVC and Web Forms stack up against each other in each category.
Team experience and background
Playing to your team’s strengths should never be underestimated. If you are building an ASP.NET web application, chances are you have .NET developers on your team. If your team has strong Web Forms expertise or come from a Win Forms background, writing a greenfield web application using ASP.NET MVC might be a hard sell. If you do not have a team of Web/Win Forms veterans, ASP.NET MVC starts to look appealing. The reason is that the MVC pattern is extremely popular and embraced by many web based frameworks outside of the Microsoft world. Ruby on Rails, Cake PHP, Spring MVC, Django are all popular frameworks that implement the MVC design pattern and a developer coming from any of these backgrounds should easily become comfortable with ASP.NET MVC. This implies that hiring productive developers to maintain and extend your application will likely be easier if you chose ASP.NET MVC. Many say that MVC has a steeper learning curve when compared to Web Forms development for those with no web development experience. I will stray from the herd and disagree with that assessment. Web Forms employs partial classes, a complex page event lifecycle, and simulated state which operates contrary to the way the web works. MVC is simple to explain because it does not mask the web being a stateless protocol. Instead it embraces how users interact with a web server and provides a clean pattern in which to do so.
Integrate applications across the enterprise for improved data integrity and consistent processes
The word extensibility get thrown around a lot, what are we really talking about here? Extensibility is a measure of how easy it is to make changes to your application, from small feature additions to large infrastructure changes. Imagine you decide to completely change the database technology you use to back your application. For example, maybe a NOSQL database will suit your technical needs perfectly and want to save money by not purchasing SQL Server licenses. This change would frighten some Web Forms teams, unless they took extreme care and were very diligent in building a sound infrastructure. If a developer decided to bind some controls directly to a SQL server data source using a connection string, making your database switch could be a nightmare. On the other hand, ASP.NET MVC makes it very easy to decouple layers of your application. For example, it is very simple to set up and use a dependency injection framework because controllers are just simple classes.
Third Party Tools
Web Forms is a mature framework and has plenty of third party controls and tools that make some tasks incredibly easy. The Ajax control toolkit, Telerik, Infragistics, etc. all provide some awesome functionality out of the box in the form of custom controls. These third party offerings can save a ton of development time if they meet your needs. While Web Forms has the upper hand in the form of third party tools that generate page content, ASP.NET MVC is able to make better use of tools that are geared toward quality code. Dependency injection, mocking, and unit testing tools are able to be used to their fullest extent in ASP.NET MVC projects with little set up effort. Web Forms projects are at a disadvantage when it comes to using these tools, as the framework itself makes it difficult to enforce the decoupling required for the tools such as Ninject, Moq, and NUnit to be useful.
Design and Device Targeting
Is your web application going to be viewed on a mobile device? Today, the answer to that question is almost always yes. Web Forms provides mobile support in the form of custom device adapters that create custom rendering for a control based on the type of browser that is making the request for the page. While using Web Forms it is necessary to create a different page in your application for both desktop and mobile devices. To target multiple devices using ASP.NET MVC, you would create views that are specific to mobile devices and one view specific to desktop browsers. The key here is that by leveraging the routing feature of ASP.NET MVC, there is a potential to use the same controller action to service a request for a page on a mobile device, as well as a desktop PCs, and only the view returned from the action will change. This is a great example of what we gain from using the MVC design pattern. Since the view is decoupled from the model, we can easily create multiple views that display the same data in a different format.
Hopefully this blog series has helped educate you on the key advantages and disadvantages of both ASP.NET Web Forms and ASP.NET MVC. The discussions above should be a good starting point when deciding which technology to use on your next web development project. Remember to stay objective and keep in mind that ASP.NET MVC and Web Forms are both capable technologies and choosing one over the other does not spell doom, nor guaranteed success, for your project. Credera has experience implementing and extending robust web applications built using ASP.NET Web Forms and ASP.NET MVC for companies including Radio Shack, GameStop, Alpha Natural Resources, and Interstate Batteries (to name a few). If you have questions about which technology makes the most sense for you project or have other questions about Microsoft Development, please contact us for more information.