Can I pass non-string to WCF RESTful service using UriTemplate?

前端 未结 4 617
我在风中等你
我在风中等你 2020-12-02 21:54

Can I do the following?

[OperationContract]
[WebGet(UriTemplate = \"/foo/{id}\")]
string GetFoo(int id);

I\'d like my service to function a

4条回答
  •  借酒劲吻你
    2020-12-02 22:33

    As dthrasher mentioned, move id to the query part of the URI. This worked for me:

    [OperationContract]
    [WebGet(UriTemplate = "/foo?id={id}")]
    string GetFoo(int id);
    

    See "URI scheme" on wikipedia for more info about the different parts of a URI: http://en.wikipedia.org/wiki/URI_scheme

提交回复
热议问题