WCF adding trailing slashes
I’ve run into some weird issues, which I’ve finally figured out, when building the Zoopcast web service, which will eventually become the REST API for Zoopcast when we’ve got a useful number of users and a stable API.
The problem is that if there is an empty URI, WCF expects a trailing slash, and will helpfully redirect you to it. That’s what you’d usually expect when you get to a directory on a web server. But it’s not what I want.
It turns out that it’s by design. If I put everything under one giant WCF service, it would be fine, as there wouldn’t be an empty URI (e.g. it would be “users” rather than “”), so there would be no redirect.
I think the only way that I can fix this is by using IIS’s URL rewriting to rewrite “users” to “users/”. It’s not the most ideal solution, but it will work for now. I prefer that than to create an über web service.
Any other suggestions welcome!
UPDATE: Seems that my solution (I should have tried it before I posted it) doesn’t help. I think it’s to do with there being two methods that have the same URL template. One for POST, one for GET. It’s annoying. Another update (if I remember) to come…