Skip to content

Minimal APIs and controllers treat header arrays differently #54978

Closed
@gurustron

Description

@gurustron

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Passing comma-separated list of values to the header is treated differently by controller action and Minimal API endpoint during binding to array. For controller action they are parsed as separate values while for Minimal APIs - as single one:
Controller action:
image

Minimal API:

image

Expected Behavior

Should behave the same way.

Steps To Reproduce

Create controller with action:

[HttpGet]
public IActionResult Get([FromHeader] string[] hs) => Ok(new { Test = hs});

And minimal API endpoint:

app.MapGet("/test_h", ([FromHeader] string[] hs) => new {Test = hs});

And pass request header hs: 1,2,3

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etchelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions