ASP.NET MVC Folder Structure

Before Going to ASP.NET MVC Folder Structure

In the Previous Lecture , we created a new ASP.NET MVC 5 application. We learned different steps which need to be followed when creating MVC 5 Web application. We saw every step in detail that how to create ASP.NET MVC application. After creating the application successfully, we build the application and run it in the browser. There we also saw that VS created a file hierarchy which we are going to discuss as ASP.NET MVC Folder Structure.

asp.net mvc folder structure

 

What is ASP.NET MVC Folder Structure:

In the above figure, you can see that there are a lot of folders and files that VS created for ASP.NET MVC Application. We will look at all one by one.

  1. Properties: It contains AssemblyInfo.cs file which contains all information about your project. Information about GUID, project name, copyright, trademark etc.
  2. References: Next one is references. It contains all libraries references which are being used by this project. References about ‘System’ libraries, ‘Microsoft’, ‘XML’, ‘JSON’, ‘LINQ’.

App_Data

This folder is empty when a project is created. As you start creating the database then its related files are stored in this folder. Data Files like LocalDB, .mdf files.

App_Start

This folder contains configuration files which are necessary for a project to be compiled and run. There are three .cs files in this folder. BundleConfig.cs, FilterConfig.cs and RouteConfig.cs. The most important one and of our concern is RouteConfig.cs. It contains default routing path of ASP.NET MVC application. As we are creating MVC based application so, the controller is always in control. You can see in the image that default controller is ‘Home’, the default action (method or function) is ‘index’ and id is optional (means only use in get, update, delete queries). You can change this routing scheme.

asp.net mvc folder structure

 

Content

Content folder contains bootstrap, css, images and other resource files. MVC automatically add bootstrap.css, bootstrap.min.css and site.css for the responsive behavior of the site.

Controllers

This folder contains all controllers which are using in the project. By default HomeController.cs (controller attribute in RouteConfig.cs is pointing towards this controller) is added which shows us homepage of ASP.NET in the browser.

Fonts

This folder is almost of no use in many cases. It has different formats of glyphicon files. You can add custom glyphicons as you desire.

Models

All models reside in this folder. Right now it is empty but when you start building your backend logic, models must be added in here.

Scripts

It contains jquery files which add more responsiveness to your pages.

Views

This folder contains .cshtml files. If you are doing frontend development then you are more interested in this part of ASP.NET MVC folder structure. Every controller creates its own view folder. ‘Shared’ folder contains common layouts which can be invoked from any view.

Global.asax File

This file has code that runs at the application level. Like Application_Start, route, bundle and other configurations.

Packages.Config File

This configuration file is managed by NuGet. It gives you detail about installed packages. Whenever you install a new package it appears in this file.

Web.Config File

It contains application level configuation details like package configurations, validations, publicKeyToken, id etc.

 

Other Topics and Categories

 

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: