Introduction to MVC

Model-View-Controller (MVC) is an architectural pattern. This pattern separates an application into three components Model, View and Controller. The MVC framework is a lightweight and highly testable presentation layer that is integrated in web form applications.

MVC-1.jpg
MVC Architecture

MVC-2.jpg
In a traditional web forms application:

Problem with ASP.Net Web form

Web form applications introduced the event-driven approach and also introduced View State and post-back. Both post-back and view state create problems, in other words view state affects the performance of the application (sometimes the web page has hundreds of KB of View state). The developer does not have any control of the rendering of the server control. Also the Page lifecycle of an ASP web form is too complex. In a web form application, a single class displays the user interface and handles the user controls.

There is no predefined project structure like MVC for creating a web form based application. One may use or follow their own style of coding and practice. Also Code behind is tightly coupled with the UI.

The Separation of Concern has not been fit with web form based applications. Also automated testing is very difficult in a post-back model.

Advantages

The following are the advantages of MVC:

Disadvantages

Even if the MVC pattern comes with many advantages, there are also some disadvantages too.

Advantages of web form based application

The following are the advantages of web form based applications:

MVC based application Visual Studio web form based application

MVC based application Web form based application
It supports the Test Driven Programming model It supports the Event Driven Programming model that preserves state over the HTTP.
There is no event in MVC. The Web Forms-based application provides many events and also is supported in many server controls.
It uses the Front Controller pattern that process all requests through a single controller. It uses the Page Controller pattern that adds functionality to individual pages.
MVC does not support view state. It supports view state on server based forms that can help us to manage state information.
MVC has no specific page life cycle. All individual components (such as Model, View and Controller) have their own life cycle. There is a specific page life cycle in the web form page.
MVC supports Separation of Concerns (SoC) that provides the highly organized code structure. In MVC all three parts can be developed and worked independently. Web forms support Rapid Application Development (RAD). The components are tightly integrated.
MVC is an extensible and pluggable framework. We can create our own view engine to render the view, we can also plug in a URL routing policy and other components. MVC also supports DI and IOC. MVC also supports multiple View Engines such as ASPX ,RAZOR, and so on. A Web form does not support customized view engine.
MVC follows the design of the stateless nature of the web. Whereas web forms preserve state over HTTP.
Code behind is not tightly coupled with the View (User Interface). Code behind is tightly coupled with the View (User Interface).
MVC also supports existing markup such as ASP.Net page (.aspx), user control (.ascx) and master page (.master) as view templates.
MVC also supports existing ASP.NET features such as authentication (form and windows), authorization, membership and roles, caching, session state and profile state management.
There is a loose coupling among the three components of an MVC application that also supports parallel development.
The ASP.NET MVC framework is a lightweight alternative of web form based applications.

Conclusion

The selection of technology varies from person to person. MVC has a few advantages, such as more control over HTML; support of TDD, builtin support of SEO based URLs, and so on. If you want these benefits then you can choose the MVC model. A Web form's abstraction of the Web provides a stateful environment, while MVC is consistent with the Stateless nature of the web. I think, testability, refactoring capability and maintainability are the main factors of any application. The MVC model allows us to create highly testable and loosely coupled applications with Test Driven Development (TDD) and Separation of Concerns (SoC). Now the complete decision of the team's and project's requirements to choose technology between web forms or MVC.