Middleware is a software assembled into an app pipeline to handle request and response.
In simple words middleware gives us the facility to add additional logic before and after the HTTP request.
We can use middlewares for following purposes:
- Caching
- Logging
- Routing
- Static Files
- Rate Limiting
- Compression
- Authorization
- Authentication
- Error Handling
- Content Type Negotiation
- CORS (Cross-Origin Resource Sharing)
We have three ways to create middleware:
- Request delegate
- By convention
- Using middleware factory
I already wrote an article about how to create middlewares, you can read it here and if you enjoyed that make sure to subscribe my newsletter for more amazing content ??
https://dev.to/ashu_rajput/what-is-middleware-and-multiple-ways-to-create-middleware-in-net-core--32li

Top comments (0)