Is there a simple way to have multiple UriTemplates in the same definition.
[WebGet(UriTemplate = "{id}")]
For example I want /API/{id} and /API/{id}/ to call the same thing. I don't want it to matter if there is / at the end or not.
Is there a simple way to have multiple UriTemplates in the same definition.
[WebGet(UriTemplate = "{id}")]
For example I want /API/{id} and /API/{id}/ to call the same thing. I don't want it to matter if there is / at the end or not.
This is only partially helpful, but the new WCF Web API library has a property on the HttpBehavior called TrailingSlashMode that can be set to Ignore or Redirect.
Not really simple, but you can use an operation selector in your behavior to strip the trailing '/', like in the example below.
The easiest way I found to do this is to overload the function as explained here.