Understanding the Backend Entry Point
Explore how the ASP.NET Core backend entry point initializes your web application, configuring services and the request/response pipeline. Understand middleware execution order, React app integration in development and production, and how to add custom middleware for tasks like logging.
We'll cover the following...
An ASP.NET Core app is a console app that creates a web server. The entry point for the app is a method called Main in a class called Program, which can be found in the Program.cs file in the root of the project:
This method creates a web host using Host.CreateDefaultBuilder, which configures items such as the following:
The location of the root of the web content
Where the settings are for items, such as the database connection string
The logging level and where the logs are output
We can override the default builder using fluent APIs, which start with Use. For example, to adjust the root of the web content, we can add the highlighted line in the following snippet:
The last thing that is specified in the builder is the Startup class, which we’ll look at below.
Understanding the Startup class
The Startup class is found in Startup.cs and configures the services that the app uses, as well as the request/response pipeline. Here, we will understand the two main methods within this class.
The ConfigureServices method
Serv ...