Web Forms have been around for a while, and is probably not going anywhere in a hurry. The good thing (or bad, depending on how you want to look at it) is that now you have support for the MVC pattern (Check the System.Web.Mvc namespace). All right, so now that you have the options, which one do you pick?
ASP.NET Web Forms
ASP.NET Web forms has been around for a long long while and is quite mature as a technology. This is the traditional ASP.NET and there are tons of developers who can develop using Web Forms. This was Microsoft’s attempt to bring the VB style of development to the web. Support for designers, drag-n-drop and the event driven model makes it easy to learn and much like the VB style development.
Of course, its biggest strength is also its biggest weakness. While the ViewState and PostBack hide the inherent statelessness of the web and provide the developer with a event driven model, it also leads to pages that are unnecessarily slow. The rich set of controls provide ease of development, but in the process the developers also lose control over the rendered html.
- Hides the statelessness of web
- Mature technology, tons of controls
- Event driven model, feels like Windows development
Model–view–controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.
MVC frameworks have been available for JSP, PHP, RoR and others, but its only recently that ASP.NET got MVC. When you develop with MVC, you are are pretty close to http and html. You know that http does not maintain state and you account for it. You write your own views and that renders the application exactly as you asked it to be rendered. The advantages are:
- Control your output exactly
- Clear separation of concerns
- Ease of unit testing
So which one is for me?
Short Answer: It depends.
Long Answer: Its depends on your team and requirements. If you are a believer in Agile or TDD, MVC will work great for you. If you need control over the rendered HTML, again MVC should be your choice. If you need to develop an application in the smallest possible time frame, your best bet will be Web Forms. And if you are just starting with ASP.NET, then pick MVC – once you figure out how to work with MVC, you will always be able to go back and pick up Web Forms.
And of course, you can always mix-n-match. MVC and Web Forms can happily live together in the same application.