liveBook · Manning

Pipeline reexecution

As explained in ASP.NET Core in Action, 3e

Pipeline reexecution is the process of running a request-processing middleware pipeline again for a different path after an exception or other handling condition.

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.

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains the rerun and its failure modes, but stops short of implementing custom reexecution mechanics.
Examples
Uses / and /error paths, ExceptionHandlerMiddleware configuration, dynamic page failure, and JSON error generation.
What it assumes
Assumes familiarity with middleware pipelines, exceptions, request paths, and generated HTTP responses.
What you can do after
Operate/configure ExceptionHandlerMiddleware with an error path and avoid fragile error-handling pages.
How it connects
Connects middleware pipeline, exception handling, production error pages, static responses, and JSON responses.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.