MVC application folder structure

In the previous article, you have learned to create your first MVC application. In this article, we will focus on the folder structure of a basic MVC application. You have seen the following folder and files structure which was created by the Visual Studio.

Let's understand about them one by one.

App_Data

App_Data stands for application data, which can contain various types of application data files. These files can be like XML file, .mdf file, Local Database(LocalDB) file etc.

App_Start

App_start stand for application start, which basically contains the class files which gets executed when the application starts. Following are most important files.

  • BundleConfig: Used to create the bundle of JavaScript and CSS files
  • FilterConfig: Used to do the request filtering
  • RuteConfig: Used to create the routes

Content

Content folder contains the static files or the files which do not change frequently. These files can be CSS files, image files, font files, text files etc which can be used across the whole application.

Controllers

Controller folder contains the controller class files. Controller classes are basically responsible to handle the user's request. These classes deal with the flow of the MVC application, they handle the data coming from the user and responds with a relevant View with a specific Model if required.

fonts

However you can put the fonts in the Content folder as well, here we have a separate folder to store the font files.

Models

Models folder contains the entity classes, these classes further contains the different types of properties based on the requirement. Model classes manage the data which is used to represent the output using Views.

Views

Views are the presentation layer of MVC framework. Views are basically the templates where we write the scripts. Mainly these scripts consist HTML, JavaScript, etc. Although views can have a number of content types as well.

Scripts

Scripts folder contains various types of JavasScript files. When the project is created visual studio automatically adds the JavaScript files for Jquery and bootstrap. Here you can store other JavaScript files like Angular, KnockoutJs etc as well.

Global.asax

In this file, we can write the global events such as Application_BeginRequest, Application_Start, Application_Error, Session_Start, Session_End etc. These events run on the application level, global error or other global events can be handled from this page.