tags:

views:

18

answers:

1

I have a RESTFul WCF service with a url likes this

groups/{groupName}/members

which returns a list of users this works fine for normal groupNames. But when I use a groupName with a special char (like #) nothing is returned ex. when the url

groups/c#/members

is called from the client it only returns null. I put a break point in the service code but the service's method is not even executed.(Break point never gets hit)

Also I tried using the url encode to encode c# as c%23 but the result is still the same. I tried this with built in web server of VS 2010 and IIS 7 but the result is still the same.

And I am using .NET 4.0 Any help will be really appreciated

A: 

In a url the hash indicates the end of the url and what follows it is a reference to a specific portion on the page, so the url /groups/c#/members is interpreted as the url /groups/c (and then the browser tries to take you to the href on the page named "/members".

Basically you should never allow # as a character in your dynamic url's. There's a reason people generate permalinks with only alphanumeric characters separated by dashes, and it's not just for readability/SEO. Some characters just plain aren't allowed. You should look at having a permalink field in your application so groups might have a name of c# which you display on page, but also a url friendly version of the name like c-sharp.

Jeremy
The url encoding of the string is a good try, but the browser treats the encoded version, and the un-encoded version exactly the same, in regards to the behaviour I describe.
Jeremy