我正在使用Web API(ASP.NET MVC 5的一部分),并尝试将查询字符串的值绑定到Dictionary<int, bool>
。
我的Web API方法如下:
[HttpGet]
[Route("api/items")]
public IQueryable<Item> GetItems(Dictionary<int, bool> cf)
{
// ...
}
如果我尝试调用这个URL:
/api/items?cf[1009]=true&cf[1011]=true&cf[1012]=false&cf[1015]=true
这个cf
参数始终是null
。
我如何通过查询字符串向Web API方法传递值字典?
.key
/.value
)-最终我只能手动迭代Request.Form
并手动解析结果。 - qJake