Project Structure of an ASP .NET Core application
.NET Core .NET

Project Structure of an ASP .NET Core application

Mishel Shaji
Mishel Shaji

In the previous tutorial, we’ve learned how to create an ASP .NET Core application. In this post, we’ll learn about the project structure of an ASP .NET Core application. Also, we’ll learn about some important files in the project.

The project structure

If you open the solution explorer of the project which we have created in our previous tutorial, you will find it similar to the one shown below.

ASP .NET Core Tutorial - Project Structure
ASP .NET Core Project Structure

Important files and folders

.csproj

.NET Core 2 uses the .csproj file to manage the project. To edit the file, Right-click on the project in Solution Explorer and select Edit <Project-Name>.csproj.

This is how my .csproject file looks like.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"/>
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
  </ItemGroup>

</Project>

It simply holds some information related to the .NET Framework and other packages used in the application.

If you are using .NET Core 1, probably you will not have this file. Instead, .NET Core 1 uses project.json file to manage the project.

Properties

This node contains only one file – launchSettings.json. This file holds the project specific settings of each debug profiles.

Here’s the launchSettings.json of my project

 "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:9881",
      "sslPort": 44304
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "ASPCoreWeb": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Dependencies

This folder holds all the server side and client side dependencies, libraries and frameworks (such as Bootstrap, Jquery) used in the application.

wwwroot folder

By default, this is considered as the root folder of the project. In ASP .NET Core, static files saved only in the wwwroot folder can be server over an HTTP request.

You can use another folder instead of wwwroot by specifying it in the Program.cs file. We’ll learn more about it later.

Program.cs

This is the entry point of your application. Also, you can change the configuration of your application in Program.cs.

Startup.cs

The earlier versions of ASP use System.web assembly that took care of starting the application. You could also provide custom logic in the global.asax file.

But with ASP .NET Core, things have changed. global.asax and System.web assembly is gone. In ASP .NET Core, Startup.cs determine how to start the application.