Similarities and Dissimilarities Between MVC and Web Forms

First of all I’d like to wish you A Happy New Year 2014. A New Year with new aspirations and fresh thoughts. After a short interval I thought I will write a new article on the grooming technology, MVC.

To explore MVC further, today I am sharing some interesting facts about the similarities and dissimilarities of MVC and Web Forms.

I have seen many articles that state dissimilarities between both, however there are also few similarities also that I’ll list.

ASP.Net MVC / Web Forms Similarities

The following are some similarities; they both:

  1. Are built on the ASP.Net Framework
  2. Are in the System.Web namespace.
  3. Use .Net Framework supported languages.
  4. Use an IIS and ASP.Net request Pipeline, for example HTTP Handler and HTTP Module.
  5. Send the response back to the client in the form of HTML.
  6. Also support third-party controls.

ASP.Net MVC / Web Forms dissimilarities

The following are some dissimilarities.

ASP.Net MVC ASP.Net Web Forms
View and logic are separate, it has separation of concerns theory. MVC 3 onwards has .aspx page as .cshtml. No separation of concerns; Views are tightly coupled with logic (.aspx.cs /.vb file).
Introduced concept of routing for route based URL. Routing is declared in Global.asax for example. File-based routing .Redirection is based on pages.
Support Razor syntax as well as .aspx Support web forms syntax only.
State management handled via Tempdata, ViewBag, and View Data. Since the controller and view are not dependent and also since there is no view state concept in ASP.NET, MVC keeps the pages lightweight. State management handled via View State. Large viewstate, in other words increase in page size
Partial Views User Controls
HTML Helpers Server Controls
Multiple pages can have the same controller to satisfy their requirements. A controller may have multiple Actions (method name inside the controller class). Each page has its own code, in other words direct dependency on code. For example Sachin.aspx is dependent on Sachin.aspx.cs (code behind) file.
Unit Testing is quite easier than ASP.Net Web forms Since a web form and code are separate files. Direct dependency, tight coupling raises issues in testing.
layouts Master pages

I hope these facts may help you to understand the similarities and dissimilarities between MVC and Web Forms .I tried to keep it simple to understand the fact in an easier manner.

Enjoy Coding and stay Happy.

Sachin Kalia


Similar Articles