liveBook · Manning

UseStartup<>

As explained in ASP.NET Core in Action, 3e

UseStartup<> is a host-builder method that specifies the Startup class used to configure an ASP.NET Core application.

UseStartup<Startup>() tells the ASP.NET Core host which Startup class configures dependency injection, middleware, and endpoints. section 30.7

Place it inside ConfigureWebHostDefaults when building an IHostBuilder. Startup separates frequently stable host bootstrapping from application configuration that changes as features grow. section 30.2

Register Startup in Program.cs

public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); section 30.2

The referenced Startup class typically provides:

  • ConfigureServices(IServiceCollection) to register dependency-injection services. section 30.7
  • Configure(IApplicationBuilder) to add middleware in pipeline order and register endpoints. section 30.7

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains placement, Startup responsibilities, dependency injection, middleware ordering, and explicit routing requirements.
Examples
Uses a Program.cs CreateHostBuilder method with Host.CreateDefaultBuilder and ConfigureWebHostDefaults.
What you can do after
Apply it via IHostBuilder to connect a web host with a conventional Startup-based application configuration.
How it connects
Connects the generic host with IHostBuilder, Startup, dependency injection, middleware pipelines, endpoints, and configuration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.