Middleware
In this section, we will introduce middleware, which is one of the most important improvements in ASP.NET Core.
To follow this section, you can run the following command to create a new ASP.NET Core web API project:
dotnet new webapi -n MiddlewareDemo -controllers
You can download the example project named MiddlewareDemo
from the chapter’s GitHub repository.
What is middleware?
ASP.NET Core is a middleware-based framework. An ASP.NET Core application is built upon a set of middleware components. Middleware is a software component that is responsible for handling requests and responses. Multiple middleware components form a pipeline to process requests and generate responses. In this pipeline, each middleware component can perform a specific task, such as authentication, authorization, logging, and so on. Then, it passes the request to the next middleware component in the pipeline. It is a huge improvement over the traditional ASP.NET framework, which...