Pipeline reexecution runs the middleware pipeline again on an error-handling path after ExceptionHandlerMiddleware captures an exception. The alternate path generates the response shown to the client. section 4.3.2
Keep these practical limitations in mind:
- Reexecution can fail again when the error page repeats the original problem, causing the exception to propagate as a raw 500 response. section 4.3.2
- Prefer a simple or static error page that is unlikely to throw another exception. section 4.3.2
- Reexecution cannot recover a response whose bytes have already started streaming to the client. section 4.3.2
Generating an error response
Configure app.UseExceptionHandler("/error") in production and map /error to a response. If a request to / throws, the pipeline runs again using /error to produce the result.
