dotnet / dotnet/aspnetcore

Provide a way to debug HTTP Response headers

Open
#47,366 3 comments 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I was trying to add cache headers in my middleware, but it was not applied.

Since I had no way to debug it to find out why they are not applied (other than cloning and debugging the source code of ASP.NET Core), I created https://github.com/dotnet/aspnetcore/issues/47303.

There, with the help of @mitchdenny I realized that a `ResponseCache` attribute was overriding my middleware value.

I had no way to find out this. I think it's a good idea if we can find out a report on **why and how** the current HTTP Response Headers are created.

For example, how about `dotnet run --verbose` or `dotnet run --report:http-response-headers` or something similar to allow us to find out why the current headers are generated.

### Describe the solution you'd like

I think a good solution would be to get a log report. For example:

```
HTTP Response Headers:
Cache-Control:
Middleware.cs:25:context.Response.Headers["Cache-Control"] = "max-age=31536000";
ImageController.cs:16:[ResponseCache(Duration = 30)]
````

This will make it extremely transparent and easy to debug.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.