-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Minimal APIs and controllers treat header arrays differently #54978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gurustron Thanks for reporting this issue! Minimal API's binding logic processes all arguments that are annotated with On the other hand, MVC's aspnetcore/src/Mvc/Mvc.Core/src/ModelBinding/Binders/HeaderModelBinder.cs Lines 109 to 118 in 207bc7d
I'd classify this as a bug in minimal APIs. I don't see any reason that we shouldn't handle enumerable types correctly, particularly because so many headers pass their values as a comma-seperated string. I'm going to mark this as help wanted in the backlog. It's not high priority but I'd be happy to review or provide guidance on a PR. |
Hi, I am able to setup the environment and replicate the problem. However, I am looking for a document or steps to debug aspnetcore repo. For example, if I just print "hello world" within aspnetcore repo, where will it appear? Thank you |
@tongsean9807 Documentation for building the code can be found here: Build the ASP.NET Core repo If the instructions for debugging aren't clear from that, then maybe some improvements/clarifications can be made. My flow on my Windows laptop is typically:
|
it will be a breaking change so, what's the right approach here? should we change how array inputs work in minimal-api?! |
Here's the relevant section of the HTTP RFC https://www.rfc-editor.org/rfc/rfc9110.html#section-5.2 which clearly designates comma as the character for separating values in a header. |
…#58251) * #54978 * update EndpointParameterEmitter * update snapshots * go back 4 commits in googletest * imporove BindParameterFromProperty(...) readability * get coverage for both compile-time and run-time code gen with a single test case. * merging main * Revert "go back 4 commits in googletest" This reverts commit ba2d730. * Revert "merging main" This reverts commit b618f3c. * empty * add caching for GetHeaderSplit MethodInfo
Is there an existing issue for this?
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:
Minimal API:
Expected Behavior
Should behave the same way.
Steps To Reproduce
Create controller with action:
And minimal API endpoint:
And pass request header
hs: 1,2,3
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: