UseStatusCodePagesWithReExecute configures status-code middleware to reexecute the request through an error-handling path. This lets the application return a friendly, dynamically generated page while preserving the original status code. section 15.5
Configure a reexecute path
Add app.UseStatusCodePagesWithReExecute("/{0}"); to the application pipeline. A failed request with status code 404 is reexecuted using /404, which generates the HTML response while the browser still receives 404. section 15.5
app.UseStatusCodePagesWithReExecute("/{0}");
The listing shows the format-string configuration used to map a status code to an error-handling path. section 15.5
Choose a path the application can handle reliably. Dynamic error pages keep application-generated content consistent, but a static page is safer when the error-handling path might fail. section 15.5
