2013-10-15 27 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}