Skip to content

HttpRequest.Headers returns odd result in multiple headers of same type #62738

@shawnwildermuth

Description

@shawnwildermuth

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When accepting a HTTP request with multiple headers of the same type, the collection returns a single element with values separated by a comma.

For example:

GET http://localhost:8888/weatherforecast/
Accept: application/json
Accept: application/xml
app.MapGet("/weatherforecast", (HttpContext ctx) =>
{
  var accepts = ctx.Request.Headers["Accept"];

  return accepts;
})

The result is that the variable accepts returns a single element with both headers concatenated:

Recording.2025-07-15.211805.mp4

Expected Behavior

If the HeaderValue returns a collection, it should return a collection of strings, not one string.

Steps To Reproduce

testheaders.zip

This is a repro case

Exceptions (if any)

No response

.NET Version

10.0.100-preview.5.25277.114

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions