liveBook · Manning

ExceptionHandlerMiddleware

ExceptionHandlerMiddleware is ASP.NET Core HTTP middleware that intercepts unhandled exceptions and generates or redirects to an error response.

How 2 Manning books explain it

ASP.NET Core in Action, 3e

Error-handling middleware is middleware that intercepts application errors and modifies the HTTP response before it is returned to the client.

How it is used
Handles unhandled application exceptions in production middleware pipelines while returning controlled, user-friendly responses.
How deep it goes
Explains response replacement, environment-based registration, and pipeline reexecution, but defers building custom middleware.
Examples
Uses /error endpoints, generic JSON or plain-text responses, and branded Razor Pages error pages as concrete handlers.
What you can do after
Configure it via UseExceptionHandler to deliver safe production error responses without exposing sensitive application details.

Read how ASP.NET Core in Action, 3e explains ExceptionHandlerMiddleware →

Building Web APIs with ASP.NET Core

ExceptionHandlingMiddleware is HTTP middleware that catches exceptions and forwards relevant error information to a configurable error handler.

How it is used
Handles application-level HTTP exceptions safely in staging and production while routing failures to a controlled error endpoint.
How deep it goes
Explains environment selection, route implementation, response generation, testing, and customization, but not middleware internals.
Examples
Uses /error controller and Minimal API endpoints, deliberate test exceptions, and environment or configuration switches.
What you can do after
Operate/configure ASP.NET Core exception handling with a safe error route and customize status codes, logging, or notifications.

Read how Building Web APIs with ASP.NET Core explains ExceptionHandlerMiddleware →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.