Skip to content

Middleware and the ASP.NET Core Request Pipeline

Middleware and the ASP.NET Core Request Pipeline

Section titled “Middleware and the ASP.NET Core Request Pipeline”

ASP.NET Core handles each request by passing it through an ordered middleware pipeline. Each middleware component can inspect the request, perform work, call the next component, and shape the response.

  • exception handling
  • HTTPS redirection
  • authentication and authorization
  • CORS
  • logging and diagnostics
  • endpoint execution

Middleware order changes behavior. For example, authentication and authorization must run before protected endpoints execute.

Keep middleware for cross-cutting concerns. Keep business logic in application services and endpoints.