How to get your WCF Web API DELETE verb working on IIS6

I’ve just had to deal with a problem on Windows Server 2003 (IIS 6.0) where my web API decided not to respond to the DELETE verb. Apparently, this is by design.

It doesn’t happen when you’re in development mode using the VS web server, so I didn’t catch it when I was developing. When I went to put it on the test server, deletes would fail. Fiddler would report a 501 Not Implemented error was returned by the server. I initially thought I’d messed up the resource mappings, but it wound up being the server configuration.

Your first response might be to head over to the application configuration on the server and simply add the missing verbs to the existing mappings. But WCF web APIs don’t have a file type, so there’s no mapping for you to edit!

To fix it, you need to setup a wildcard mapping on the server. A wildcard mapping allows you to specify an ISAPI handler that is run after every other mapping is attempted. It’s a kind of catch-all; hence the name.

Here’s how to set up a wildcard mapping:

  1. Open the IIS Manager snap-in.
  2. Use the treeview to navigate to the web site or application hosting your API.
  3. Right-click the application and select Properties.
  4. On the Virtual Directory tab, click the Configuration button.
  5. On the Mappings tab, click Insert next to the Wildcard application maps list.
  6. In the Executable text box, enter the path to the aspnet_isapi.dll version that your API is built for.
  7. Click OK to close the mapping dialog.
  8. Click OK to close the Application Configuration dialog.
  9. Click OK to close the properties dialog.
  10. Go delete something!

It’s not hard to fix the problem, in the end.