REST WCF Service - Consume QueryString Parameters

梦想与她 提交于 2020-01-05 07:57:30

问题


I have this REST WCF service.

[WebInvoke(UriTemplate = "/GetNames/{Category}?order=asc", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
public List<Names> GetNames(string Category)
{
    //Code to retrieve Names by category.
}

The Category parameter is mapped to {Category} in the Uri.

But how can I map the order query string in the Uri to this method?

Adding the order as a parameter method is not working.

please help. thanks in advance.


回答1:


Have you tried - "/GetNames/{Category}?order={ordering}" in the Uritemplate and in the function

public List<Names> GetNames(string Category, string ordering)
{
  //Code to retrieve Names by category.
}


来源:https://stackoverflow.com/questions/5431669/rest-wcf-service-consume-querystring-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!