As the name suggests, middleware is a component placed between our application and incoming requests. Incoming requests hit the middleware's pipeline before they can reach the effective logic implemented in our application. As a result, middleware are considered one of the essential concepts of ASP.NET Core because it is the first layer in front of our application, and it is usually associated with cross-cutting concepts such as logging, error handling, authentication, and validation. It can also perform advanced tasks such as conditional service initialization, based on a request.
In general, middleware can:
- Handle, process, and modify incoming HTTP requests
- Handle, process, and change outgoing HTTP responses
- Interrupt the middleware pipeline by returning an early response
Furthermore, the whole ASP.NET Core stack is composed of middleware. Middleware...