Immerge Technologies Blog

Jeremy Blanchette Jeremy Blanchette

Jul 07, 2009

ASP.NET: Forms vs MVC

I've now had 30+ hours experience using the MVC framework for ASP.NET and have had a blast learning the ins and outs of its basic structure and use. As anything else in programming, it has its pros and cons vs forms programming. On the Forms side there is the ease of using ASP.NET forms controls. Throw down a GridView, add a SQLDataSource object, add some code, and you have a fully functional datatable with easy customization. Not to mention with a simple flip of a bit, you get easy editing, deleting, and sorting. In contrast, these controls are not available in the MVC framework. You have to use all inline coding with loops and CSS to get the same effect, not to mention a lot more code (although in theory if you save it in a partial, known as an .ascx in Forms, you would only have to write this code once). Someone might wonder where the advantage is with using MVC in this certain case. The answer would be in the separation of data. The MVC Controller passes in the Model, which would consist of a DataTable object, and then the View would create the html page based off that table. In ASP.NET forms, You have the aspx file, which is basically your front-end file, doing some code and some interpreting, but then you would also have your code-behind file doing other things. This can cause a real hassle when trying to debug code. Not to mention the biggest hassle of all when it comes to ASP Forms: the page life cycle. But that can be saved for another post. As I work more with MVC I will continue to make additional posts about the pros and cons of working with each.

Return to Blog Index