Answer
Middleware are components that process HTTP requests and responses in a sequence known as the request pipeline.
- Each middleware can inspect or modify the incoming request.
- It may call the next middleware in the pipeline or short-circuit and generate a response.
- On the way back, it can also modify the outgoing response.
The pipeline is used to implement cross-cutting concerns such as authentication, logging, routing, static file handling, CORS, and endpoint execution. This model replaces the older HTTP modules/handlers, offering a more flexible and composable design.