Skip to content

Microsoft ASP.NET Model View Controller (MVC) Pattern

Model View Controller (MVC) Design Pattern

A Model View Controller is a software design pattern that’s commonly used for developing user interfaces. This architectural pattern helps to separate concerns and layers. It divides the program logic into three interconnected elements:


  1. Model – Provides data and associated logic to the view as the database table definition
  2. View – Renders the model to the view with HTML tags or elements
  3. Controller – Interacts with the model and views, and acts as a server-side method defining with input and output that will appear with a page as view

Using the MVC pattern for websites, requests are routed to a controller, which is responsible for working with the model to perform actions and/or retrieve data. The controller chooses the view to display and provides it with the model. The view renders the final page based on the data in the model. The authentication system includes libraries, a database, and template pages for handling logins, including multi-factor authentication and external authentication, or OAuth with Facebook, Google, and more.


Model Responsibilities

The model in an MVC application represents the state of the application and any business logic or operations that should be performed by it. Business logic should be encapsulated in the model, along with any implementation logic for persisting the state of the application. Strongly typed views typically use view model types designed to contain the data to display on that view. The controller creates and populates these view model instances from the model.

The following code demonstrates an example of how a model class can look like.



View Responsibilities

Views are responsible for presenting and displaying the content through the user interface. They use the Razor view engine to embed .NET code in HTML markup language. There should be minimal logic within views, and any logic in them should relate to presenting content. If you need to perform a great deal of logic in view files in order to display data from a complex model, consider using a view component, view model or view template to simplify the view.

The following code demonstrates an example of how a view class can look like.

Microsoft ASP.NET MVC Pattern


Controller Responsibilities

Controllers are the components that handle user interactions, work with the models, and at the end, select a view to render to display it. In an MVC application, the view only displays information or data values. The controller handles and responds to user input and interactions. In the MVC pattern, the controller is the initial entry point and is responsible for selecting which data model types to work with and which view to render in the HTML page.

The following code demonstrates an example of how a controller class can look like.

MVC Pattern


ASP.NET MVC Application In Summary

The Model View Controller software design pattern is commonly used for developing user interfaces. For more information about MVC, refer to