8

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.

1
  • See how a similar problem was solved on IIS 7.5 here. The solution is elegant. Commented Sep 19, 2010 at 13:28

2 Answers 2

4

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!

Sign up to request clarification or add additional context in comments.

2 Comments

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
Gotta love those "undocumented" features. :) Glad it worked for you.
2

If your web application is getting deployed to multiple dev/production environments, then the best way seems to be disable WebDAV at the web.config level. To do this, remove the WebDAVModule and the WebDAV handler as in the below example:

<system.webserver> <modules> <remove name="WebDAVModule" /> </modules> <handlers> <remove name="WebDAV" /> </handlers> </system.webserver> 

2 Comments

the question was how to enable PUT and DELETE in IIS on an application level.
Yes, this will cause IIS to allow it for just the current application, without enabling it globally, as the original poster asked. If you do not remove the WebDAV module and handler, PUT and DELETE requests will get hijacked by them and will not work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.