tags:

views:

138

answers:

2

I created a WCF REST (aka WebHttp) service in .NET 4, using Microsoft's WCF REST Service Template 40. I am hosting the service in IIS 6.

The Service Template uses the RouteTable in the Global.asax as a way to create "clean" URL's that don't include ".svc" in them. For example:

http:// localhost / flights / 878

GET and POST work fine against this URL, but PUT and DELETE result in HTTP 501, "Not implemented".

If I create a simple .svc file like this:

<%@ ServiceHost Language="C#" Debug="true" Service="MyProject.FlightsService"%>

then I can use PUT and DELETE against this URL:

http:// localhost / flightsservice.svc / 878

Does anyone know if it's possible to get PUT and DELETE to work against the "clean" URL above? It seems that there is no way to configure IIS to allow this because there is no file extension to configure settings for, and I don't want to allow PUT and DELETE globally. Thanks!

+1  A: 

I haven't worked with IIS6 in a while (and I don't have it installed, so I'm going off memory here), but I had to implement something similar with IIS6 for routing extensionless URLs in IIS6.

You can enable wildcard script mappings on a folder by folder basis by hacking IIS Manager. This blog post is what I followed and it works really well (and this link provides a little more background). It's really a bug in the Manager, not IIS itself (at least that's what I tell myself).

Can you reference your services in a sub-folder in your site (e.g. http://localhost/services/flight/878)? If so, and if you implement the IIS Manager hack above, I think you can enable all HTTP verbs for that directory. Again, I'm going off memory (and we only implemented GETs and POSTs, so I didn't deal with PUTs and DELETEs), so I hope I'm getting this right.

Let me know if you need more info or if my memory is slipping. :) I hope this helps!

David Hoerster
Thanks, this worked! Since my IIS application will contain only services, I set the wildcard mapping for the entire application as described in the second link you posted. Thanks very much! Mike
Mike Taverne
Gotta love those "undocumented" features. :) Glad it worked for you.
David Hoerster
A: 

See how a similar problem was solved on IIS 7.5 here. The solution is elegant.

lmsasu