Issues with WebApi Delete and Update Commands

Another day at the office.

After running through some Pluralsight training in relation to WebApi development my colleagues and I discovered whilst trying to follow the tutorial that Delete and Update methods (PUT and DELETE verbs) implemented within the controller classes would not seem to work. A little bit of head scratching, double checking and digging later revealed that the issue was due to a configuration issue with IIS8. It seems that out of the box IIS8 ships with the verbs PUT and DELETE disabled. The issue was resolved very simply by:-

1. Opening the IIS8 ApplicationHost.Config file located within the directory ‘%userprofile%\documents\iisexpress\config”

2. Change the “Verb” values from the following line

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

to read

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

Note the inclusion of the PUT and DELETE verbs.

3. Now recompile and run your code, which should restart your web server and hey presto your Delete and Update methods should work as intended.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s