In this post, we will see what is MVC and how we can use it in our ASP.NET web applications.

MVC – Model, View, Controller

MVC pattern is one of the most popular design patterns these days and almost all the technologies whether Java, Rails, PHP have MVC frameworks to work with.

MVC design pattern makes developing web applications much more easy and standardized. It provides lot of pre-defined functionalities that we can use in our application.

MVC patten encourages strict isolation between the individual parts of the application.

MVC design have three components:

  1. Model
    Model represents the business logic of the application. Models are responsible for representing entities of the project. They also use to save or retrieve the data from database.
  2. View
    Views represents the display of the web application which is created with the help of Html, Images, JavaScript, CSS etc.
  3. Controller
    Controllers contains methods that represents URLs in the application. A controller acts as an intermediate between view and model.


Advantages of MVC
  1. It provides a clean separation of components.
  2. It is easier to test each component separately.
  3. It facilitates de-coupling of application layers with the help of dependency injection.
  4. It is easy to scale the application.
  5. It is easy to customize views by using different templates.
Directory Structure of ASP.NET MVC Project

Here is the directory structure of a typical ASP.NET MVC project:














  • App_Data
    This directory organizes all the components of the application. We will be writing most of our code under this directory.
  • App_Start
    This directory contains the bundle, rails and rake executables that are needed to execute various rails commands
  • Content
    This directory contains images and CSS files.
  • Controllers
    This directory contains controller class files.
  • fonts
    This directory contains fonts we can use in our web application.
  • Models
    All your application logs will be stored here.
  • Scripts
    This directory contains JavaScript and similar files.
  • Views
    This directory contains folders with the name of controllers. Each folder contains view files corresponding to actions in the controller.
  • Global.asax
    This file contains methods corresponding to events in your web application like application start, session created etc.
  • packages.config
    This file is managed by the NuGet package manager. It is used to track installed packages with their respective versions.
  • Startup.cs
    This file contains class that helps in adding and configuring various middle wares in the application like Autofac for dependency injection.
  • Web.config
    This is the main settings and configuration file for an ASP.NET web application. It is an XML document that resides in the root directory of the application and contains data about how the web application will act.

There are other files/directories in the project that are generated dynamically as we add more stuff.

Creating your first mvc project