Folder Structure In Asp.NET MVC

Folder Structure In Asp.NET MVC:

A MVC project contain a numbers of folder and subfolders and follow structure architecture . There are three folders that present in each project that are: View, Model and Controller folder. Folder structure of Asp.Net MVC project depend upon the project templates.  In this article we read about the folder structure of a project and also read the use of each folder.
First go to File-> New-> Project -> Asp.Net Web Application.

Now click on MVC Project.

After creation the project now go to “Solution Explorer” and view the folder structure of project.

We can see that out project contains multiple folders and each folder also contain some sub folders. Now we read about these folder structure and also read the purpose of each folder in project.

App_Data Folder:

App_Dode folder store classes related to the database. Usually SQL Server Express .mdf files are stored in App_Code folder. Files stored in App_Code folder are automatically accessible throughout the application.

App_Start Folder:

App_Start folder contain the files that are required during the launching of the application like routing table infor, start up files, and Filter configuration files.

Content Folder:

The content folder contain the files related to the style sheet.

Controller Folder:

This folder contain all the controller using in project. Each controller name contain “Controller” as postfix.  This is name convention for controllers which we need to follow in mvc.

Fonts Folder:

This folder contain various files that denotes the fonts for application like ttf, svg and woff.

Model Folder:

Model folder contain the class that represents the data for application. These classes used to access, stored the data from database.

Scripts Folder:

Script folder contain various files related to JavaScript, jQuery and other types of the scripting files.

Views Folder:

View folder contain all the files that will be show to the user. We can see that with respect to each controller a view subfolder is generated and this subfolder contain a views related to the controller.  View folder also contain a Shared folder that contain the views that will shared with other controllers.

Web.Config file:

We can see that two Web.Config(in View folder and main web.Config) files are present in project. Now a question is arise why we need two Web.Config files. First we understand the purpose of Web.Config file in View folder. The web.config in the views folder is there to block direct access to the view aspx pages which should only get served through controllers.
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>

 Web.Config in the /Views folder is a great (if not thé) way to declare namespaces specifically for your views in.
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />


Post a Comment

Online Casino