Some Dictionaries do not get model bound #1418
Comments
cc @kichalla This issue seems to repro in WebAPI 2.3.2, so we might be able to port this fix back to WebAPI. |
@pranavkm What is the behavior in MVC 5? |
may also need to change |
See: RoundTrippedValues_GetsModelBound_ForStringIndexedProperties for a functional test that needs to be updated |
@pranavkm did you do the comparison to MVC5? |
Just FYI...I have tried in MVC 5 and it also didn't support this.. |
what about Web API 3? |
Pranav and I investigated earlier(please take a look at the earlier comment in this bug) about this for 2.3.2 and it was not supported there too.. |
Clearing milestone so we look at this again. |
We need to make sure we can model bind everything that our HTML helpers generate. |
I'm surprised to say MVC 5 supports binding to |
…entries - #1418 - add new fallback binding in `DictionaryModelBinder` - similar to MVC 5 approach but more explicit and with better key conversion support - fix bugs in `PrefixContainer` encountered while adding new tests of #1418 scenarios - did not handle entries like "[key]" or "prefix.key[index]" correctly - refactor part of `GetKeyFromEmptyPrefix()` into `IndexOfDelimiter()`; share with `GetKeyFromNonEmptyPrefix()` - extend `ReadableStringCollectionValueProviderTest` to cover bracketed key segments nits: - remove use of "foo", "bar", and "baz" in affected test classes - `""` -> `string.Empty` - `vpResult` -> `result`
…entries - #1418 - add new fallback binding in `DictionaryModelBinder` - similar to MVC 5 approach but more explicit and with better key conversion support - fix bugs in `PrefixContainer` encountered while adding new tests of #1418 scenarios - did not handle entries like "[key]" or "prefix.key[index]" correctly - refactor part of `GetKeyFromEmptyPrefix()` into `IndexOfDelimiter()`; share with `GetKeyFromNonEmptyPrefix()` - extend `ReadableStringCollectionValueProviderTest` to cover bracketed key segments nits: - remove use of "foo", "bar", and "baz" in affected test classes - `""` -> `string.Empty` - `vpResult` -> `result`
…entries - #1418 - add new fallback binding in `DictionaryModelBinder` - similar to MVC 5 approach but more explicit and with better key conversion support - fix bugs in `PrefixContainer` encountered while adding new tests of #1418 scenarios - did not handle entries like "[key]" or "prefix.key[index]" correctly - refactor part of `GetKeyFromEmptyPrefix()` into `IndexOfDelimiter()`; share with `GetKeyFromNonEmptyPrefix()` - extend `ReadableStringCollectionValueProviderTest` to cover bracketed key segments nits: - remove use of "foo", "bar", and "baz" in affected test classes - `""` -> `string.Empty` - `vpResult` -> `result`
Consider the model
The name generated by
Html.NameFor(v => v.Values["height"])
isValues[height]
however this expression does not get model bound.There's a gap in the collection model binder where it only attempts to bind numeric keys. The right fix for this would be to call into
IEnumerableValueProvider
and then bind each key and value independently and add the result to the dictionary.The text was updated successfully, but these errors were encountered: