A middleware to provide specific html pages for some error and default one for others while returning correct http error code as status: Re-execute the middleware pipeline with the StatusCodePages Middleware to create custom error pages.

We can also want to know the original path that actually caused the error: pretty easy using Request Features in ASP.NET Core and querying for IStatusCodeReExecuteFeature. In fact, current implementation of this interface also provides error query string (but it will not be reflected into interface before .Net 2.0): Retrieving the path that generated an error with the StatusCodePages Middleware