Folder Structure Of ASP.NET Core MVC 6.0 Application

In this article, we are going to discuss the Folder Structure Of ASP.NET Core MVC 6 . 0 application. In the previous post, we have created an ASP.NET Core MVC 6.0 project. Here is the link.

Let’s Get started:

1: Open the project:

Go to your folder in which you have created your project and double-click on the solution file. Now the project is opened and you can see the folders in solution explorer.

Folder Structure Of ASP.NET Core MVC 6

Now let’s understand the folder structure.

2: Open “.csproj” file:

Right-click on your project file and select “Edit Project” to open “.csproj” file.

Open ".csproj" file

After clicking on this you can see this code. First of all, in this file, you can see the project SDK. This project is using “Microsoft.NET.Sdk.Web”. After this, properties have been defined by the project in the <PropertyGroup> tag. In the <PropertyGroup> we can see the <TargetFramework> tag that has the .NET version of the project. The <Nullable> tag can be enabled and disabled with this property project nullable reference types can be handled. In the <RootNamespace> we have our project name. In <ItemGroup> we have <PackageReference> tag you can understand by its name its have our installed package reference. I have included “Microsoft.EntityFrameworkCore” in this package to my project so now our project has the reference to it.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>aspnet_core_mvc_6._0_demo_mycodebit</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
  </ItemGroup>

</Project>

3: Connected Services:

Connected Services

This connected services have all the services of connected Azure or cloud databases. We can configure azure or cloud services using this section.

4: Dependencies:

Dependencies

In the dependencies folder, we have all the libraries, packages, and projects on which our project depends.

5: launchsetting.Json file:

launchsetting.Json file

In the Properties folder we have the launchsetting.Json file. As you can see in this JSON file we have mainly application URL and port settings. We can set the environment variable in this file that is commonly used in every application.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:50150",
      "sslPort": 44375
    }
  },
  "profiles": {
    "aspnet_core_mvc_6._0_demo_mycodebit": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7228;http://localhost:5228",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

6: wwwroot:

wwwroot

In the wwwroot folder, we have all the static files of our project like CSS, JavaScript, and other static libraries. You can see the subfolders for CSS, JavaScript, and other libraries.

7: Controllers:

Controllers

In the controller’s folder, we have .cs files and these controllers have all the business logic of the application. The models and views don’t directly interact with each other.

8: Models:

Models

In the Models folder, we have data classes and view classes that we use to show data in UI. We can add multiple ViewModels and database classes in this as per our project demand.

9: Views:

Views

In the views folder, we have .cshtml files that are used for the User interface. We can change our application’s front end by changing the code in our views (.cshtml) files.

10: appsettings.json file

appsettings.json file

When you click on the appsettings.json file you will see the JSON code as I mentioned below. We can configure the database connection string in this file and also can set logging in the project.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

11: Program.cs file

Folder Structure Of ASP.NET Core MVC 6

Our applications are based on the program.cs file because this file has the run and host configurations of our project. We can configure the Service of our project that we use with IServices interfaces in our program.cs file.

Conclusion:

In this project we have learned and discussed the folder structure of ASP.NET Core MVC 6.0 Application. If you have any queries or suggestions about this post do not hesitate to contact us or comment below.

Leave a Reply

Related Posts