As an ASP.NET developer, how do you know whether to pick ASP.NET WebForms over MVC (Model, Controller, View) when developing new web projects? I tend to follow these 5 simple rules to help me determine which platform suits me best.
Are you working with a team?
You are only as strong as the weakest link. The skill level of each team member is an important factor in choosing what development platform to use. MVC has a steep learning curve involved (Yes! I had to go through these grueling stages as well). And if the majority of your team isn’t comfortable working with MVC, it is probably smarter to choose WebForms.
Data Intensive vs. Rich Client Project
If the web project involves a lot of data, data grids and filtering/sorting/grouping options and maintenance pages, then WebForms is the way to go. If the web project requires a lot of client-side manipulation and ultimate control over the rendered HTML, I would certainly choose MVC. Implementing Ajax, JSON and Jquery is a breeze in MVC.
Rapid Application Development
If the project has a tight budget and/or deadline, WebForms has a slight advantage over MVC. ASP.NET Webforms was created with reusability in mind. The familiar drag and drop controls are very helpful in rapidly creating web pages in a few clicks. However, you lose control over the rendered HTML and more importantly there is a performance hit with the added VIEWSTATE.
Ultimate control over HTML
One of the main advantages to using MVC over WebForms is complete control over the rendered HTML. Although you tend to type more when creating the web elements manually, you have complete control on styles, properties, etc. With WebForms, the HTML is automatically generated for you. This even gets more complicated when using third-party controls, since they have their own different implementation and rendering. Although it is possible to create HTML elements manually using repeater controls or data item templates, MVC has a cleaner way of doing so.
MVC was created with testability in mind. The MVC pattern has clean separation of concerns and fits well with Test Driven Development. Although possible, it’s really hard to implement automated testing in WebForms with its coupled behavior and event-based model.
Good luck, and happy coding!