The MVC Architecture


Asp.Net Websites rely on page-based approach where each page of the website represented as physical file. Asp.Net website has some level code separation where HTML mark-up stores in .aspx page and actual code stores in .aspx.cs file. These .aspx and .aspx.cs files has some level of coupling.

Microsoft introduced Asp.Net MVC in 2008 which differs from page-based approach and it rely on Model-View-Controller approach. Both Asp.Net website and Asp.Net MVC are developed on common Asp.Net framework only.

The MVC pattern maintains very strict isolation between different parts of an application. The main purpose of maintaining the application in different parts is to achieve both short-term and long-term benefits. The MVC pattern provides several benefits in Development, Testability, and Maintenance areas.

The MVC pattern divides into three different layers called Model, View and Controller. The MVC pattern looks as shown below.

 

The Model: The Model in MVC pattern represents the business logic and data which encapsulates business logic, properties of domain entity.

The View: The View represents the Model in the visual representation. That means View fetches the data from Model and displays on UI. The View can be in any format HTML, PDF, XML…etc. MVC has strong isolation between components View should focus on only data representation not on any business logic.

The Controller: The Controller in MVC pattern controls application logic and acts as coordinator between View and Model. View sends data to Controller, Controller works with the Model on the data and send the output to View.

In MVC pattern all components maintained in isolated manner, no component depends on any other component. So developers can work independently on their own components. In MVC pattern all components are loosely coupled. It makes very easy way to test the components even in production also without calling database. That means if you want to test any production component pass some static data to that component instead of actual production database call. This avoids unnecessary data modifications to the production database. Maintaining the MVC application is very easy because if you want to do any modifications for particular component it is very easy to do as components are isolated each other.