Saturday, 6 March 2021

Project Structure in ASP.NET Core 3.1 Web Application

In this article, we will learn about the Project Structure of the ASP.NET Core 3.1 Web Application. This is the continuation of the ASP.NET 3.1 Tutorials series. I will recommend you to go through the below article of this series if not already gone through that:

As in the previous article, we created an empty ASP.NET Core Project and the structure of the project is as shown in the below image.
Let’s start exploring each folder and file that exists in the Project Structure for ease of understanding.

.csproj File: Right-click on the project and then click on Edit Project File in order to edit the .csproj file (In .NET Framework we can’t see that option until the project is unloaded from the solution explorer and the content of .csproj was quite difficult to understand).
Once clicked on Edit Project File, .csproj file will be opened in Visual Studio as shown below.
As you can see TargetFramework element specifies the target framework of our ASP.NET Core application. Netcoreapp3.1 is the TFM that stands for the Target Framework Moniker. On adding the dependencies through NuGet, it will add another ItemGroup element which contains the details of the Package in PackageReference element.

launchSettings.json: Properties folder contains a file i.e. launchSettings.json file which contains all the information required to launch the application. It contains the profiles through which the application can be run, each profile is mapped to a commandName, applicationUrl on which application is launched, environmentVariables, etc.
As you can see, In the above launch setting we have two profiles. One will launch the application on IIS Express and another through the Kestral Server (used in the case when the application is run through the DotNet CLI or profile is selected through the Visual Studio Launch icon).

appsettings.json: In .Net Framework, we store application-level settings or configuration in the web.config. In the .Net Core framework, appsettings.json will do the same work. All the connection strings, application-related settings are stores in the appsettings.json file in JSON format.

Program.cs: Program.cs file contains the main method which is the entry point for the application. It will create a web host builder and configure the services defined in Startup.cs file.

: Startup.cs file used to define all services used in the application and configure the HTTP Request pipeline with the use of middleware components. It contains ConfigureServices method where you can register the services, classes with the use of built-in DI Container, and Configure method which is used to configure the HTTP Request Pipeline. Request pipeline is configured with the help of middleware components. We will learn in detail about the middleware component in the up coming article of this series.

wwwroot Folder: A wwwroot folder needs to be created in order to serve and store static files like CSS, Javascript, images, icons, etc. We will see its usage when we learn about the Static Files in the upcoming articles of this series.

Another interesting feature of the ASP.NET Core Project that files in the project are sync with the files in the system in real-time. Let say on adding a file through the file explorer in the project (not through Visual Studio), files created/altered immediately reflected in the Solution Explorer window. If we delete any file through file explorer, the file will be deleted immediately from the solution explorer as well. In the older version of .Net Framework, we need to include and exclude files manually if files added/deleted through the windows explorer window.
I hope this article helps you in understanding the basic Folder/Project architecture of the ASP.Net Core project.


Post a comment

Subscribe Now

Popular Posts

Contact us


Email *

Message *

Subscribe us on YouTube

Like us on Facebook