Can I use an object in a UriTemplate?

I tried the following code:

 [OperationContract]
 [WebInvoke(UriTemplate="/Users/Register/{user}")]
 void Register(User user);

But when I try to run this, it tells me that the UriTemplate should only contain strings. What should I do if I need to pass an object to my method, as in this case, the User object for my Register method.

If I change the WebInvoke attribute to:

[WebInvoke(UriTemplate="/Users/Register/")]

Browswer displays an error Method not allowwhen I try to go to http: // localhost: 8000 / Users / Register , for example

+5
source share
3 answers

UriTemplate. , . , URI, POST/PUT. GET . , :

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate="/Users/Register")]
void Register(User user);

User, Uri, POST.

+6

, . URI . . , , , , URI.

0

( ? - ?). .

0

All Articles