ExceptionHandlerMiddleware
ExceptionHandlerMiddleware is ASP.NET Core HTTP middleware that intercepts unhandled exceptions and generates or redirects to an error response.
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
- UseExceptionHandlerconfigured by · UseExceptionHandler is an ASP.NET Core pipeline-extension method that configures handling for unhandled exceptions.
- middlewarekind of · Middleware is an intermediate software component or layer that processes or mediates requests, messages, or operations between other components, often adding behavior or controlling their flow.
- pipeline reexecutionuses · Pipeline reexecution is the process of running a request-processing middleware pipeline again for a different path after an exception or other handling condition.
- IProblemDetailsServiceuses · IProblemDetailsService is an ASP.NET Core service interface that generates Problem Details responses for errors.
- exception filteralternative to · An exception filter is an ASP.NET Core MVC filter that processes exceptions not handled by an endpoint or other applicable filters.
- DeveloperExceptionPageMiddlewarealternative to · DeveloperExceptionPageMiddleware is ASP.NET Core middleware that catches unhandled pipeline exceptions and generates a detailed diagnostic error page for developers.
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.

