tags:

views:

469

answers:

1

I wrote a simple REST Collection WCF service with REST Start Kit Preview 2. The template project provides a Service class with a Dictionary collection instance as its internal collection items. Each item has a key and a value.

The problem is that if the key contains a '.' such as 'ProductA.Item1', then my query to a specific item will not work. The url GET request to this item is something like:

  http://localhost:1247/Service.svc/ProductA.Item1

It looks like that IIS treats the URL as a resource instead of passing xxx.xxx as a parameter to my REST service's OnGetItem(string id) method. If I remove the part of '.Item1' (building the internal collection with none-dot-like keys such as 'ProductAItem1'), it works fine.

I even tried to change me WebGet attribute's UriTemplate to Products({id}), and then tried this customized URL:

  http://localhost:1247/Service.svc/Products(ProductA.Item1)
  http://localhost:1247/Service.svc/Products('ProductA.Item1')

Still I cannot reach to my code OnGetItem(string id) method. Without dot-like keys, the customized URL works fine as well.

I am not sure that dot or '.' in URL is a special character by IIS server or not. How can I escape it or make it like string parameter with dot inside if it is special char? Or I just cannot use the dot in my URL at all?

A: 

I believe the problem you are having is caused by the way the classes in System.Web.Routing work. Apparently this used to be a problem for the ASP.NET MVC guys (see blog post) but according to that post by Phil Haack, the problem is supposed to be fixed. Maybe the REST starter kit does not use the new Routing dll yet?

Darrel Miller
That's very possible. The routing service might block the call to OnGetItem(). I'll double-check in ASP.Net Forum. Thanks!
David.Chu.ca