The ASP.NET Core pipeline

On the ASP.NET Core pipeline, we can add middleware in two ways: inline code in an anonymous function, or reusable middleware components. Both are added to the pipeline in a sequential way in the Configure() method in Startup.cs.

When the Configure() method is invoked, the HTTP pipeline is prepared and set up to handle incoming requests. These incoming requests are passed into and threaded by each piece of middleware added to the pipeline.

In the next recipe, we will learn how middleware, works with inline code. Inline code for middleware is not the best practice. It's more relevant to create middleware classes and use the app.UseMiddleware method to add them to the pipeline for various reasons (reusability, clarity, ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.