Explain Middleware in ASP.NET Core?

Technology CommunityCategory: ASP.NETExplain Middleware in ASP.NET Core?
VietMX Staff asked 3 years ago

Middleware is actually sequential series of delegates (piece of code), that can either short-circuit or pass on the HTTP request to next delegate. These are known as middleware, a concept well known to people who worked with Node.js.

Piece of your middleware can do one of the following:

  • Handle an incoming HTTP request by generating an HTTP response (maybe your authentication or authorization middleware will stop the request early and immediately create response)
  • Process the incoming request, change it and pass it to the next middleware in the pipeline
  • Process the outgoing response, change it and pass it on to next middleware in the pipeline or directly to the ASP.NET Core web server