Using WebAPI? Disable WebDAV To Avoid PUT/DELETE Issues

This one turned out to be a right head scratcher!

A WebAPI that worked fine in development, but as soon as I deployed it to the live server, any DELETE command started returning “500 – Internal Server Errors”. I stripped the code back as far as I could, to the point where the DELETE function was only returning a string. Nada, still getting errors.

I checked the request directly from the server, so it would bypass the standard error page, and give me the real error. It was all down to WebDAV.

It turns out that by default on IIS, WebDAV will be configured as the default binding for DELETE and PUT requests.

If you disable WebDAV (which it was by default), it STILL remains the default binding! IIS passes the requets to WebDAV, which immediately rejects it, due to it being disabled. Thus causing the 500 error.

If you are using WebAPI, then you need to disable the module WebDAV in your web.config file, as follows:

<modules>
  <remove name="WebDAVModule"/>
</modules>
<handlers>
  <remove name="WebDAV" />
</handlers>

Read More