-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Minimal Actions - array support in method signatures from querystring binding #32516
Comments
Would this only be for simple types? Today we don't support any complex types for model binding and it conflicts with this idea |
Yup simple types only imo, it's a query string, you shouldn't be doing crazy stuff like json binding. I mean there's nothing stopping someone adding json in a querystring I just don't think the framework should support that |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
What collection types should we support? What should we do if we know the param comes from the route? Fail at startup? Provide a single-element array? |
With the newly added support for |
This is where this typically falls of the rails. There are A LOT of collection types including custom types that implement collection interfaces. It's possible we can do something like pattern match a This currently also conflicts with JSON bodies sent as arrays so it would need to be explicitly declared as @JamesNK I'd like your feedback here.
I think fail. This should work for headers and query but not route. Open questions:
Reasons to avoid anything except for arrays in this scenario:
So strawman proposal is:
|
@jchannon This is supported in .NET 7 preview1 |
I mean preview2 |
Previously (in Framework) you could serialize an array of primitives to a JSON object in the query string like this:
(escaped obviously) and the method:
would bind correctly. That doesn't appear to be the case in .NET6 (or possibly earlier). I assume that was a known breaking change but I thought it worth asking? If it was not an intentional change then it's a different bug I guess. |
This issue isn't about MVC's binding semantics and minimal API supports a subset of what MVC supports. If you want to see what is supported for MVC today look at https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-6.0#collections |
Thanks. Sorry this seemed like the closest issue to what I'm experiencing that wasn't locked by the bots. |
😄. FWIW, it's not supported in MVC either, that's by design. |
Describe the bug
When using the ASPP.NET 6 minimal hosting, querystring binding does not work with arrays/lists
To Reproduce
Adding
[FromQuery(Name = "values")]
to the method signature does not help either.Exceptions (if any)
An exception is thrown when sending in a request:
curl http://localhost:5000/qs/123\?name\=dave\&values\=1\&values\=2
Unhandled exception. System.InvalidOperationException: No public static bool Int32[].TryParse(string, out Int32[]) method found for values.
Further technical details
The text was updated successfully, but these errors were encountered: