Reputation: 53
I'm new to REST service development and I am currently writing a WCF Rest Service which must support an existing calling format.
I know that by adding
[WebInvoke(Method = "GET", UriTemplate = "{id}/testid.xml")]
string testid(string id);
to my webmethod the request will be made using:
http://[hostname]/255/testid.xml
What I want is to be able do make the request using http://255/[hostname]/testid.xml
Please note that the service is hosted in a Windows Service Application.
Thanks for your help!
Upvotes: 1
Views: 737
Reputation: 31780
You can't. The structure of a given URI is as follows:
This can be broken down into:
URI templating works on the Path and Querystring components of the URI only. The Scheme and the Authority cannot be accessed in this way.
Upvotes: 1
Reputation: 84
It is not possible. you can't add parameter or can't pass parameter in uri before domain name and service name. You can add parameter after domain and service name in Uri.
Upvotes: 0
Reputation: 1235
To use special characters inside parameters on the URL you must configure the HttpListenerRequestUriBuilder. This builder unescape or not the encoding based on a setting. You can add this code to your app.config file:
<configuration>
<system.net>
<settings>
<httpListener unescapeRequestUrl="false"/>
</settings>
</system.net>
</configuration>
Upvotes: 0