If you were given a chance to start a new project based on ASP.NET MVC or Web Forms which technology would you use? I think many of us would choose MVC due to its novelty and increasing popularity but good ol’ Web Forms is not a bad choice either. Let me explain.
Recently I have had a discussion with my colleagues about the refactoring/rewriting of an old web application built upon ASP.NET Web Forms. This application is a larger system’s administrative interface with the task of displaying and managing information on thousands of users, groups and other organizational items. As user demands grew we were asked to investigate the possibilities of improving the performance of the app. The key challenge is to provide a responsive user interface besides an excessive increase in the amount of data to display and handle. After a short dispute on the architectural requirements we have agreed that an Ajax based smart client is the most suitable for our needs on the client side. It supports a scalable, easily accessible, efficient and fancy solution. We can finely control the client-server data flow, decrease the pressure on the server by delegating UI tasks to the client and shape the user interface as we like. Having Ajax on the client side what could we have on the server side?
Well, it is really no matter. Both frameworks support Ajax calls and actually that is all we need. If you stick with ASP.NET Web Forms then use web methods with the ScriptMethodAttribute. In case of ASP.NET MVC it is even simpler. Just define a controller action with the proper return type.
But then which framework to prefer? Since both MVC and Web Forms perfectly support Ajax calls the real difference comes from the additional features you can exploit. MVC brings simplicity on modeling and testing side, it lets you to have full control over the generated Html code, provides SEO friendly routing for your applications and more. These features can be valuable but come for a price. MVC is not the best choice for RAD design, requires deeper understanding of Html and requires more investment in terms of development efforts. But in case of dedicated business applications or large applications with private administrative interface implementation speed and the ease of UI development has a higher importance. Nobody needs to optimize for SEO behind password protected sites or to develop fancy UI controls for administrators. The focus is on displaying and manipulating data and Web Forms has a whole family of controls to help.
Novel web applications must deal with high user expectations. There are plenty of ways to satisfy these demands but choosing Ajax gives you the benefits of being OS and browser independent without the need for any pre-installed library. Both Web Forms and MVC are capable to serve Ajax calls at the backend but they have distinctive features in focus. MVC is more suitable for lightweight public applications where control over Html code, custom routing and easy testability is important. In case Rapid Application Development is prefered Web Forms can ease the pressure on development side and can bring shorter time-to-market beside using Ajax on demand. Despite MVC is a new and popular technology with all its pros and cons Web Forms is definitely here to stay.