Minimal hosting is the default way to bootstrap an ASP.NET Core web app. WebApplicationBuilder and WebApplication keep setup in one imperative entry point, rather than splitting it between a generic host builder and a Startup class. They were introduced in .NET 6 to make getting started simpler. section 30.0 section 30.5
The two types make common setup tasks easier to find:
- Use WebApplicationBuilder.Services to register dependency-injection services. Configuration and environment are available as builder properties. section 30.5 section 30.7
- Use WebApplication to add middleware and map endpoints. It automatically adds some middleware, including routing and endpoint middleware; middleware you add still runs in the order you add it. section 30.5 section 30.7
Choosing a starting point
For a new HTTP app, start with the WebApplication-based template and keep service registration and pipeline setup together. For a queue-processing worker that handles no HTTP requests, the worker template instead builds an IHost with Host.CreateDefaultBuilder(args). An existing app using the generic host and Startup can keep that supported approach when upgrading to .NET 7. section 30.6 section 34.2.1
Minimal hosting simplifies the surface, but does not replace the generic host underneath. Choose the generic host when you need fine control over building IHost; for most new ASP.NET Core web apps, minimal hosting is the easier starting point. section 30.5 section 30.6
