2013-10-15 26 views
0

我想我的Web API来支持我不知道高级定制领域的网址查询(他们是指定的用户)在一个理想的世界我ASP.Net的Web API - 自定义网址查询绑定

ð喜欢这个URL(场事先不知道):

public string Query(Dictionary<string,string>? queryStrings) { 
    // escape query fields and values 
    // run query 
    return result; 
} 
+0

的可能重复[如何将多个参数传递给ASP.Net Web API GET?](http://stackoverflow.com/questions/10937524/how-should-i-pass-multiple-parameters-to-an-asp-net- web-api-get) – Fals

+0

在Query中执行'Request.RequestUri.ParseQueryString()'方法。 – Vladimir

+0

在现实世界中,你不能那样做。 – James

回答

0

感谢弗拉基米尔·我刚刚得到这个控制器:

http://mysite.com/api/Query?SomeField=2&SomeOtherField=value 

与这样的动作绑定

enter image description here

返回这个结果:

enter image description here

这正是我所期待的:)

{这是Web API V5 RC}