2.3 Exploring the project structure and files

Sho Shimoda
2 min readJun 29, 2023

--

In the previous session, we created a new ASP.NET Core project. Now, we will explore the structure of this project, the purpose of the different files and directories, and how they contribute to our web application. Familiarizing yourself with this structure will provide a solid understanding of how ASP.NET Core applications are organized and where various components reside.

1. Overview of the Project Structure:

After creating an ASP.NET Core project, you’ll notice several files and folders in your project directory. Here’s a brief overview:

  • wwwroot: This is the web server’s root directory. It contains static files, like HTML, CSS, images, and JavaScript files. These files can be served directly to the client’s browser.
  • Pages: In an ASP.NET Core Razor Pages app, this folder contains the Razor Pages (.cshtml files) for the application.
  • Properties: This directory holds a file called launchSettings.json, which configures settings for running the project.
  • appsettings.json: This file contains configuration settings for the application, such as connection strings.
  • Program.cs: This file is the entry point for the application. It creates a host for the app, configuring the app’s HTTP pipeline and hosting environment.
  • Startup.cs: This file specifies how the app responds to individual HTTP requests, and it also configures services used by the app.
  • .csproj: This is the project file, which contains project-level settings and references to dependencies.

2. Understanding Key Files:

Now let’s examine some key files more closely:

  • Program.cs: The Main method in this file sets up a host for the application and runs it. The host is responsible for app startup and lifetime management.
  • Startup.cs: This file is crucial for configuring your app’s behavior:
  • The ConfigureServices method: This is where you register services for Dependency Injection (DI) to use across your application.
  • The Configure method: Here you define how your app handles requests by setting up the request pipeline, composed of middleware components.
  • appsettings.json: You can use this file to store and retrieve configuration data, such as connection strings or app-specific settings.
  • .csproj: This file specifies which SDK and which version to use, and lists package dependencies. When you add a new NuGet package to your project, it’s added here.

With this overview, you should now have a basic understanding of the structure of an ASP.NET Core project and the role of various files and folders. As you gain more experience, this knowledge will make it easier to navigate the framework and develop more complex applications.

In our next session, “Building Web Applications with ASP.NET Core MVC,” we will dive deeper into the mechanics of ASP.NET Core. We’ll explore how the MVC (Model-View-Controller) pattern fits into this ecosystem and how you can leverage it to build robust web applications.

--

--

Sho Shimoda

CEO/CTO of {RECEIPT}ROLLER. We offer easy digital receipt solutions for all POS and e-commerce, eliminating paper waste.