Is there a way to have custom defined friendly URLs with WCF without IIS?
In particular I’m looking to do something like this via an app.config hosted in my own Windows service:
[WebGet(UriTemplate = "foo/{id}")]
public string GetFoo(string id)
{
...
}
Yes sure – host this inside your own NT Service, and in your
app.config, define a http base address. The URI templates you define in your service contract will be off that base address:Then your URI template will be added to this base address, so in that case, you
GetFoomethod would be callable at:Update: I just recreated this here, and the problem is this: your URI template defines a parameter called
{id}, but the method you apply this URI template to doesn’t have any parameter calledidin it’s parameter list:You need to make sure those things match! With the given URI template, you need to change your method declaration to:
(see the parameter – it’s name is now
id) and then you should be fine – at least it works just fine for me.