Join us Now |  Forgot Password? | Forgot UserName?

Asp.Net MVC

Learn step by step

MVC Architecture

The Model-View-Controller (MVC) pattern is an architectural plan concept that divides the application components of a Web application into three layers:

  • Model
  • View
  • Controller

This divisions gives you extra control over the particular parts of the application, which lets you more easily develop, modify, and test them.

The Model-View-Controller (MVC) pattern was introduced in 1970s. It is a software design pattern that breaks an application into three main features: Model, View and Controller. Moreover, MVC pattern forces a divisions of affect within an application for example, partitions data access logic and business logic from the UI.

The MVC model explain web applications with 3 logic layers:

  • The business layer (Model logic)
  • The display layer (View logic)
  • The input control (Controller logic)

The MVC Programming Model

MVC is a architecture for developing web applications using a MVC (Model View Controller) design:

  • The Model indicate the application core (for occurrence a list of database records).
  • The View show the data (the database records).
  • The Controller manage the input (to the database records).

The MVC model also delivered full control over HTML, CSS, and JavaScript.

Model - The "M" in "MVC"

Model carry and introduce the properties and application logic In a good technique we can say that The model represents core business logic and data. In the eTutOn Sample the 'eTutOn Model' class represents the properties of a “TutOn” in the application and may display properties such as Name, Location and Contact Number etc and also it may display methods.

The Model represents a set of classes that describes the business logic and data. It also explains business principles for how the data can be changed and operate.

Moreover, models in Asp.Net MVC, manage the Data Access Layer by using ORM tools as Entity Framework or NHibernate etc. By default, models are keep in the Models folder of the project.

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

Objects or ViewModel Layer

This layer have simple objects or complex objects which are used to identify strongly-typed view. These objects are used to move data from controller to strongly-typed view and vice versa. The classes for these objects can have particular validation principles which are describe by using data annotations.These classes have those properties which you want to show on equivalent view/page.

Data Access Layer

This layer gives objects to access and operate the database of your application.This layer is made by using ORM tools as Entity Framework or NHibernate .

Business Layer

This layer assists you to execute your business logic and validations for your application. Business layer make use of Data Access Layer for continue data into database. Also, this layer is instantly invoked by the Controller to do perform on input data and sent revert to view.

View - The "V" in "MVC"

The View is liable for making the response HTML or any responses back to the browser like excel,html and pdf. In other way we can set that the view is liable for modify a model or models into a visual representation.

The View is liable for modify a model or models into UI. The Model is liable for supply all the necessary business logic and validation to the view. The view is only liable for showing the data, that is received from the controller as the result.

Moreover, views in Asp.Net MVC, manage the UI presentation of data as the result of a request received by a controller. By default, views are saved in the Views folder of the project.

Controller - The "C" in "MVC"

Controller is liable for processing user inputs from view and give answer back to the view. It means that the controller judge the action and achieve the tasks/logic based on the variables.Controller acts as the coordinator between the view and the model.

The Controller is liable for handling the application logic and acts as the coordinator between the View and the Model. The Controller accept input from users via the View, then process the user's data with the assist of Model and passing the output revert to the View.

Moreover, controllers in Asp.Net MVC, respond to HTTP requests and verify the action to take based upon the content of the incoming request. Controllers are stored in the Controllers folder of the project.

ASP.NET MVC Framework

The ASP.NET MVC framework supply an another to the ASP.NET Web Forms pattern for creating MVC-based Web applications.

The ASP.NET MVC framework provides the following advantages:

  • It does not use view state or server-based forms. This makes the MVC framework perfect for developers who want full control over the behavior of an application.
  • It makes it easier to operate complexity by dividing an application into the model, the view, and the controller.
  • It uses a Front Controller pattern that processes Web application requests through a single controller. This allow you to design an application that supports a well routing infrastructure.
  • It works well for Web applications that are assists by large teams of developers and Web designers who need a high degree of control over the application behavior.
  • It provides good support for TDD(Test-driven development).

Characteristics of ASP.NET MVC Framework

  • It is a pluggable framework. Any component can be easily exchange or designed or customized.
  • Divisions of application task and testability and test driven development by default.
  • It supports URL naming pattern that work well for Search Engine Optimization (SEO) and Representational state transfer (REST) addressing.
  • Any Unit test framework which is well matched with ASP.NET can be used for testing.
  • It supports of using mark-up in existing .ASPX pages.
  • It supports uses of Dependency Injection and Inversion of Control Framework like UNITY.
  • It supports existing ASP.NET features.

Related Videos