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 would 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 a few similarities that I’ll list.
ASP.Net MVC / Web forms similarities
The following are some similarities; they both.
- Are built on the ASP.Net Framework
- Are in the System.Web namespace.
- Use .Net Framework-supported languages.
- Use an IIS and ASP.Net request Pipeline, for example, HTTP Handler and HTTP Module.
- Send the response back to the client in the form of HTML.
- 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 a 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 the concept of routing for route-based URLs. 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 is 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 is 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 and tight coupling raise 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 facts in an easier manner.
Enjoy Coding and stay Happy.
Sachin Kalia