Krishan Dutt Sharma

Web Developer

Asp.Net MVC Architecture

Asp.net MVC Architecture separates an application into three parts Model-View-Controller(MVC). MVC Architecture provides good “separation of concerns”  in general “Loose coupling”. 

Following image shows how asp.net MVC architecture flow will be

mvc-mental-model

Model- The “M” in MVC :

The model represents a set of classes that describe the business logic and data. it also defines business rules for how the data can be changed and manipulated.

Models in Asp.net MVC handles the data access Layer by using OTM tools like Entity Framework or NHibernate etc. ByDefaults, Models are stored in the Models Folder of the Project.

The Model can be broken down into several different layers as given below:

  1. Objects or ViewModel Layer: This layer contains simple objects or complex object which are used to specify a strongly-typed view. These objects are used to pass data from controller to strongly-typed view and vice versa. The classes for these objects can have specific validation rules which are defined by using data annotations.
  2. Data Access Layer: This layer provides objects to access and manipulate the database of your application. This layer made by using ORM tools like Entity Frameworks etc.
  3. Bussiness Layer: This layer helps you to implement your business logic and validations for your application. This layer is directly invoked by the Controller to do processing on input data and send back to View.

View – The “V” in MVC

The View is responsible for transforming a model or models into UI. The model is responsible for providing all required business logic and validation to the view. The view is only responsible for displaying the data, that is received from the controller as the result. By Default, Views are stored in views folder of the project.

Controller – The “C” in MVC

The controller is responsible for controlling the application logic and acts as the coordinator between the view and the model. The controller receives input from the user via the view, then process the user’s data with the help of model and passing the results back to the view.

The Controllers in Asp.net MVC, respond to HTTP requests and determine the action to take based upon the content of the incoming request. By defaults, Controllers are stored in the Controllers Folder of the Project.