What is the purpose of automatically generated directories in an ASP.NET MVC project?

6

In Visual Studio Community 2015 when we create a new project in ASP.NET MVC in the project the following directory structure is automatically generated, see the image below:

Being in total eight directories.

Question

I would like to know what is the purpose of each directory that was automatically generated?

    
asked by anonymous 28.10.2016 / 03:49

2 answers

4

Firstly, I should point out that most folders are suggestions, and do not necessarily have to be used the way they are. That said, I'll make a brief explanation of each folder.

App_Data

This folder is meant to save the physical files, if you are using it. For example: I'll upload a spreadsheet to my site and want to save somewhere. It is Microsoft's suggestion to use this folder.

App_Start

This folder contains the classes that run when your application starts. Usually comes with the BundleConfig.cs , FilterConfig.cs and RouteConfig.cs files by default (if you use the sample

fonts

Location indicated to save fonts used in your application. These are the fonts to change the letter itself, those files with the .eot , .svg , .woff , etc.

Models

Folder given to save the templates of your application. Of course, this is an indication, and if you use the Repository standard (I do not know why the rays would do this), you would not even need to use this folder. However, I would not advise doing this.

Scripts

I think this folder should be the most obvious, but yes. This folder is the place to save the Scripts of your application. And yes, the Scripts that I refer to are .js files, such as jQuery.js , bootstrap.js , etc.

Views

By default, your Views should be created in this folder. This standardization is important because of route and connection issues with Controllers . This is so recommended, that Visual Studio has a function called Go To Controller , where it opens the Controller for this View .

Views are files with the .cshtml extension, that is, the layout of your application.

There is one more folder that an application usually has (manually created), which is ViewModel :

ViewModels

In this folder your ViewModels is added. If you do not know what I'm talking about, read those answers you'll understand better.

As I said earlier, these folders are suggestions from Microsoft. It is not necessary to use as suggested. However, if you change the most important folders ( App_Start , Controllers and Views ), you will have serious problems if you do not know what you are doing. This is because the routes (I'm not talking about the RouteConfig.cs ) of the application are set to this default, but if you make changes to the folder but do not change the routes correctly, give error

    
28.10.2016 / 13:38
4

This is the basic and default structure created for a new ASP.NET MVC project. To work, you usually need the App_Start , Views , Models and Controllers folders. More experienced developers can choose to create a totally empty project and add the structures as needed. However, because it is MVC, it will probably be the Model, Controllers and Views folders.

The less common folder is APP_Data , which is generally used for file-based database storage, such as .dbf or. mdf . This is a folder that IIS will deny direct access by containing sensitive data. For example if placing image files and trying to deliver to client will not be able to access trivially.

The App_Start folder is where the Routes, Bundles, and Filters configuration files are created by default.

The Content folder is where style sheet (CSS) files are created and images can be added as well.

Controllers is where controllers, both ApiController and common Controllers are created.

Models is where the Model files are created (can be ViewModels or Models), which are representations of the business entities for example, according to the architecture. I have seen cases of no such folder, because the models are in another assembly (dll).

In this folder fonts are font files.

Scripts are JavaScript libraries (jquery, jqueryval etc)

Views are the .cshtml files.

    
28.10.2016 / 12:18