liveBook · Manning

CreateApplicationBuilder()

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

CreateApplicationBuilder() is an ASP.NET Core API method that creates an IApplicationBuilder for configuring an endpoint-specific middleware pipeline.

CreateApplicationBuilder() creates a separate IApplicationBuilder for an endpoint-specific middleware pipeline. Build that mini-pipeline, then associate it with a route through IEndpointRouteBuilder.Map(). section 31.1.5

Map a middleware endpoint

var endpoint = ((IEndpointRouteBuilder)app) .CreateApplicationBuilder() .UseMiddleware<PingPongMiddleware>() .Build(); app.Map("/ping", endpoint); The middleware runs when a request matches /ping. The cast is necessary because WebApplication hides this advanced method.

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

How deep it goes
Explains creation, middleware addition, pipeline building, and route mapping, while labeling the API advanced.
Examples
Uses PingPongMiddleware mapped to /ping and wrapped in a MapPingPong extension method.
What it assumes
Assumes familiarity with middleware and endpoint routing; teaches access through UseEndpoints or an IEndpointRouteBuilder cast.
What you can do after
Build it from scratch by composing middleware into a mini-pipeline and mapping that pipeline to a route.
How it connects
Connects endpoint routing, middleware pipelines, IEndpointRouteBuilder, Map(), and minimal API endpoints.

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.