Skip to content

[AspNetCore .NET 9] Headers lost when HttpContext is cleared in ExceptionHandlerMiddlewareImpl #63187

@daniel-dewa

Description

@daniel-dewa

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the new .NET 7 ProblemDetails-based exception handling, the middleware pipeline is not reexecuted during ExceptionHandler execution in ExceptionHandlerMiddlewareImpl.

This leads to the clearing of headers that were set during the initial middleware execution,
after problem details are returned in DefaultProblemDetailsWriter.

Have I misconfigured my ASP.NET application / is there a correct way of reexecuting middleware when returning ProblemDetails using a custom IExceptionHandler?

Reproducible example: https://github.com/daniel-dewa/ErrorDetailsExample

Expected Behavior

I expect middleware to be reexecuted or not be cleared when returning an exception.

.NET Version

9.0.108

Anything else?

ASP.NET Core version: Microsoft.AspNetCore.App 9.0.7
Might have something to do with #51888?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions