Loading


What is ASP.NET MVC File and Folder Structure?. The Complete ASP.NET MVC Developer Course 2023 [Videos].

In this article, I am going to discuss the auto-generated ASP.NET MVC File and File Structure when we create a new ASP.NET MVC application. Please read our previous article before proceeding to this article where we discussed how to create ASP.NET MVC 5 application step by step from scratch.

Nowadays, the ASP.NET MVC framework becomes more popular among developers because of the separation of concerns (codes) and folder structure. As a developer, it is very important for you to understand the need and use of each file and folder of an ASP.NET MVC application. When we create an ASP.NET MVC 5 application, Visual Studio by default creates the following files and for our application.

ASP.NET MVC Folder and File structure

Let us discuss the need and use of each File and Folder in detail one by one.

App_Data:

The App_Data folder of an ASP.NET MVC application contains application-related data files like .mdf files, LocalDB, and XML files, etc. The most important point that you need to remember is IIS is never going to serve files from this App_Data folder. In our example, this folder is empty as we dont have any data files. In our upcoming Videos, we will discuss how to store application-related data files in App_Data Folder.

App_Start:

The App_Start folder of an ASP.NET MVC application contains configuration-related class files which are needed to be executed at the time of application starts. The classes like BundleConfig, FilterConfig, RouteConfig, IdentityConfig, etc are stored within this folder. We will discuss the use of each of these class files in detail in our upcoming Videos.

App_Start folder of MVC application

Content:

The Content Folder of an ASP.NET MVC application contains static files such as the image files, CSS files, and icons files, etc. When we create a new ASP.NET MVC 5 application, then by default bootstrap.css, Site.css, and bootstrap.min.css files are included by Visual Studio as shown in the image below.

Content folder in MVC Application

Controllers:

The Controllers Folder of an ASP.NET MVC application contains all the controllers of your application. The Controllers are nothing but classes that are inherited from the base Controller class. The name of the Controller should end with the word “Controller”. It is this class that actually handles the users request i.e. the incoming HTTP Requests and returns a response. In our upcoming Videos, we will discuss the controllers in detail.

Controllers folder in MVC application

Fonts:

The Fonts folder of an ASP.NET MVC application contains the custom font files that are required for the application.

Fonts folder of an MVC application

Models:

The Models folder of an ASP.NET MVC application contains the class files which are used to store the domain data (you can also say business data) as well as business logic to manage the data. In our example, the Models folder is empty as we have not created any models for our application. In our upcoming Videos, we will discuss Models in detail.

Scripts:

The Scripts Folder of an ASP.NET MVC application contains all the JavaScript files that are required for your application. When we create an ASP.NET MVC 5 application, by default the necessary javascript files for jquery and bootstrap are included. If you want to create any custom javascript files then they should be created within this folder or any subfolder of this folder. This is not mandatory but it is a good programming practice as in later time you can easily find out the javascript files. 

Scripts Folder of an MVC application

Views:

The Views Folder of an ASP.NET MVC application contains all the “.cshtml” files of your application. In MVC, the .cshtml file is a file where we need to write the HTML code along with the C# code. The Views folder also includes separate folders for each and every controller for your application. For example, all the .cshtml files of the HomeController will be in the View => Home folder. We also have the Shared folder under the Views folder. The Shared Folder contains all the views which are needed to be shared by different controllers e.g. error files,  layout files, etc.

Views Folder of an MVC application

Now, let  us discuss the configuration files which are created by the framework by default:

Global.asax:

The Global.asax file in an ASP.NET MVC application allows us to write the code that we want to run at the application level or you can say global level, such as Application_BeginRequest, Application_Error, Application_Start, Session_Start, Session_End, etc. In our upcoming Videos, we will discuss the use of these application-level events in detail.

Packages.config:

The Packages.config file in an ASP.NET MVC application is managed by NuGet Package Manager which will keep track of what packages and versions have been installed in your application.

Web.config:

The Web.config file of an ASP.NET MVC application is one of the most useful and important files which contains the application-level configurations such as connection strings, global variables, etc.

Here in this Video, we discussed the ASP.NET MVC File and Folder structure. Once you understand the need and use of each folder and file of an MVC application, then it is easy for you to find, store and organize project-related files. 

See All

Comments (263 Comments)

Submit Your Comment

See All Posts

Related Posts

ASP.NET MVC / Youtube

What is MVC?

MVC is an architectural software design pattern that is used for developing interactive applications where their user interaction is involved and based on the user interaction some event handling has occurred. It is not only used for web-based applications but it can also be used for Desktop or mobile-based applications where there are user interactions involved.
28-jan-2022 /28 /263

ASP.NET MVC / Youtube

How to Creat First ASP.NET MVC Application using Visual Studio?

In this article, I am going to discuss how to create the first ASP.NET MVC Application step by step from scratch using Visual Studio 2015. You can use any version as per your choice but the step will remain the same. Please read our previous article before proceeding to this article where we gave a brief introduction to ASP.NET MVC Framework.
28-jan-2022 /28 /263

ASP.NET MVC / Youtube

What is ASP.NET MVC File and Folder Structure?

In this article, I am going to discuss the auto-generated ASP.NET MVC File and File Structure when we create a new ASP.NET MVC application. Please read our previous article before proceeding to this article where we discussed how to create ASP.NET MVC 5 application step by step from scratch.
28-jan-2022 /28 /263