I need to handle http://host.my/path?normal=1&othernormal=2&dict_a=b&dict_x=y
Here's my latest attempt at it, based off How to use Bind Prefix? :
public string Get(int normal, int othernormal,
[Bind(Prefix="dict_")]
Dictionary<string, string> dict) { ... }
That creates a dictionary, however, it is empty.
It is important to note, that dict_a
, and dict_x
are not known in advance. E.g. dict_abracadabra=bla
must be allowed.
You're able to bind these values to a dictionary without a bind prefix. A dictionary will consume any simple values in the querystring.
Your sample query and method signature (without the bind prefix), and it seems to work pretty much as expected:
I've tested this in MVC 1.1.0-preview1-final.
From the docs here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding