w3resource

ASP.NET MVC Folder Structure


In the previous tutorial, we took a bold step of creating our first MVC application. Congratulations on that. In this section, we will explore the file structure which Visual Studio gave us by default.

A typical ASP.NET MVC application has the file structure as shown in the figure below:

asp.net solution explorer 1

We will take a quick look at the significant and functions of the folders and files present the ASP.NET MVC application.

App_Data

The App_Data folder is empty by default at the point of creating the application. This folder contain certain data files like LocalDB, xml files and .mdf files. Other data related files can also be kept in this folder.

App_Start

Just like the name, it contains files which will be executed once the application starts. These are some configuration files like BundleConfig.cs, FilterConfig.cs, IdentityConfig RouteConfig.cs and Startup.Auth.cs files

asp.net app start

Content

The content folder contains static files like CSS, Icons and image files. By default, ASP.NET comes with bootstrap and some other stylings to get us started.

asp.net content folder

Controllers

The folder contains C# classes that handles the requests made on this application and returns the appropriate response. By default, MVC requires us to end our controller classes with the suffix "Controller". We will discuss more on this in the subsequent chapters.

asp.net controllers

Fonts

The fonts folder contains custom font files for your application.

asp.net fonts

Models

The Models folder contains our application model classes. Theses are classes that will be used to control and manipulate our application data.

asp.net models

Migrations

This folder contains our migration files, which are a snapshot of our model classes. The migrations files are used in creating our database off our model classes.

asp.net migrations

Scripts

The Scripts folder contains JavaScript or VBScript files of our application. By default, ASP.NET MVC 5 includes JavaScript files for bootstrap, jQuery and modernizer to enable us easily to get started.

asp.net scripts

Views

The view houses the html files of our application. The files found in the view folder usually ends with the. cshtml extension, this enables us to write C# codes in this files.

In the view folder, the view files are arranged into different controller folders. For instance, all the files controlled by the AboutController will be in the View>About folder.

The Shared folder houses views that can be shared amongst the different controllers.

asp.net views

The ASP.NET MVC applications also come bundled with some configuration files, which we will take a quick look at.

asp.net global.asax

Global.asax

This contains some high level configurations that will determine the overall behavior of our application. In the global.asax, application level events are configured.

Packages.config

Packages.config file is managed by NuGet to keep track of what packages and versions you have installed in the application. This is similar to package.json file in Node.js applications.

Web.config

The Web.config file contains application level configurations and settings, like the db connection strings etc.



Inviting useful, relevant, well-written and unique guest posts