2016-11-07 29 views
0

我需要处理http://host.my/path?normal=1&othernormal=2&dict_a=b&dict_x=y如何根据参数名称前缀从URL查询中绑定字典?

这是我在它的最新尝试,以关How to use Bind Prefix?

public string Get(int normal, int othernormal, 
    [Bind(Prefix="dict_")] 
    Dictionary<string, string> dict) { ... } 

,创建一个字典,但是,它是空的。

重要的是要注意,dict_adict_x是事先不知道的。例如。必须允许使用dict_abracadabra=bla

+0

您需要的URL是'...&字典[0] =。重点B&字典[0] .value的= y'绑定到你的参数(不'[绑定(前缀=“dit _”)]'为什么不只是参数'字符串dict_a,字符串dict_x'并创建字典的值? –

+0

@StephenMuecke,因为我不控制客户端。我的问题实际上有你的第二个答案 – LOST

+0

您将需要从查询字符串中读取值(或者创建一个自定义模型联编程序来执行此操作),并根据值创建字典。 –

回答

相关问题