The host and WebApplicationBuilder
The host
The ASP.NET Core application host is responsible for application startup and lifetime management. It encapsulates all of the application’s resources: the HTTP server implementation (KestrelKestrelThe web server inside every ASP.NET Core application.Opens in a new tab), middleware componentsThe middleware pipelineHow a request passes through a chain of components, and why their order matters.Opens in a new tab, logging, DI servicesDependency injection and service lifetimesHow ASP.NET Core hands each class what it needs, and how long each instance lives.Opens in a new tab and configurationConfiguration and the options patternReading settings from layered sources, and binding them to typed classes.Opens in a new tab.
WebApplication.CreateBuilder
In modern ASP.NET Core (since .NET 6), WebApplication.CreateBuilder(args) is used to configure and create the host and application. It sets up default services: Kestrel, configuration from appsettings.json and environment variables, and console and debug logging providers.
builder.Build() then creates the WebApplication instance. It acts as both the IApplicationBuilder and the IEndpointRouteBuilder.
Sources
- ASP.NET Core fundamentals overview, Microsoft Learn · accessed May 16, 2025