ASP.NET MVC Folder Structure


When we create an MVC basic application, there is some fixed folder structureLet's see one by one use of folders in the MVC application 

1.Properties: 


This Folder contains one code file with the name AssemblyInfo.cs. When the application is created some basic information is stored in this file like a version of the assembly, Description, configuration, Title of assembly, Copyrights, a trademark of assembly, and its culture.  

2.References: 


This is not a folder. It contains only the references added for our application sequentially.  

3. App_Data: 


Database related all items are kept in this folder means Database.MDF files. It used for XML files's so if there is no use of a Database in our project, you can simply create XML file and save it in the App_Data folder. 

4.App_Start :


Application's Route configuration, Bundle Configuration, and filter configuration related class files are stored in this folder. how the URL handle when the request came to the application is configured in RoutConfig.cs file. This is called Route Configuration.  

Another one is Bundle configuration, when our page-load on the browser, for every CSS and javascript file new request Is generated from the browser. So for minimizing these requests, we use bundleconfig.cs. In this file, we write code for bundling of many CSS and javascript in a single unit. 

Another one is Filter Configuration, Filter means some activity for each request when the user hits some URL. We see Filter Configuration in another article. 

So, In the App_start folder, we create only configuration files. And it registers when the application started means Global.asax file "Application_Start" method. 

5.Controllers: 


The controller is the main part of the MVC Architecture. When URL hits by the user route table search for which controller to call and which action method inside the controller. This folder contains a class file with a name that ends with a Controller keyword and in this class file, there is one class with a name that ends with a Controller keyword inherited from the Controller base-class(System.Web.Mvc namespace). We can add as many controllers as you can.  

6.Models: 


Models contain only class files for our real entities. Contains classes with properties for each field in the webform. It is basically used when creating HTML with c# code specified inside it. 

7.Scripts: 


This folder contains some already added javascript files, contains plugins, libraries, etc. 

8. Views: 


Views contain 2 types of files based on which view engine you are using for your application. In most of the cases, we use the ASPX engine and Razor Engine. 

If we use the ASPX engine, it creates a file with aspx extension and if we use the Razor engine, it creates a file with cshtml extension.  

Basically, View has its own structure. When we add a view for any action method, by right click on the action method, it creates a Controller name folder in the View folder, and one file added with the action method name in that folder. When we create View we can also change the name of the View. 
In the Views folder, there is by default a folder named "Shared". This folder contains all layout pages. The layout page is like a Master page in asp.net.  

One another file in this folder ViewStart.cshtml. This file contains some logic or HTML which you want to share on all layout pages and views. This VIEW executes before any other view. So we can write some common logic for all layouts or views. 

9.Global.asax 


This is one of the files in MVC architecture which contains events related to application-level like Application_start, Application_End, and some event related to Session level. We can register all configurations in this file like the above-discussed route configuration, filter configuration, etc. 

10.Web.config 


When we create a web application in asp.net or MVC platform by default this file is getting added. It contains setting related to an application like session related settings, references, key-value pairs for some keys which you want to access in the application, authentication-related settings. 

That’s all the folder structure in MVC.  


Post a Comment

0 Comments