ASP.NET MVC 5 Folder Structure

In this chapter, you will learn:
1. ASP.NET MVC Folder Structure

Before, deep diving into ASP.NET MVC 5, there are certain guidelines that you must follow in order to write MVC code properly and structured. MVC Folder Structure guides you to choose a suitable folder to store different types of files.

Solution Explorer
Solution Explorer

MVC Folder Structure

App_Data – This folder contains data files like LocalDB, .mdf files, xml files etc.

App Data

App_Start – It contains class files which gets executed when application starts. Normally it is config files like BundleConfig.cs, AuthConfig.cs, FilterConfig.cs etc.

app_start

Content – It contains static files like css files, images and icon files.

content

Controllers – It contains class files which handle user's request and response. All the controller file name ends with Controller word like HomeController, LoginController, ProfileController etc.

controllers

Models – It contains model class files which handles database task.

models

Scripts – It contains scripts file like JavaScript, VBScript, JQuery etc.

scripts

Views – It contains HTML files. There may be separate folder for each controller. For HomeController.cs; there is Home folder inside View folder.

Views

Shared - It is under view folder and it contains shared files like master page layout etc. Shared folder content can be accessed by any controller.

shared  

Some Important Files

Important Files

Global.json – This file is used for add dependencies or add external projects reference into your current project. It specifies the path where system should search for dependency folder.

Project.json – Project.json file in asp.net core is used to define project metadata, compilation information and dependencies.

Global.asax – It allows you to write code at application level events such as Application_BeginRequest, application_start, application_error, sesson_start, sesson_end etc.

Package.config – It is managed by NuGet to keep track of what packages and versions you have installed in the application.

Web.config – It contains application level configuration.

Summary

This chapter only introduces the folder structure of ASP.NET MVC5. Once you know the behavior and properties of the folder, it is easy to find, store and organize project related files. In the next chapter, you will Understand Controller in MVC5.

 

Share your thought