Deploying a WCF Data Service to a server that has WebDAV installed

Here’s a simple one, that was fairly annoying:

I deployed a WCF Data Service to a site today, and while I was testing all of the operations I found that both the PUT and DELETE verbs weren’t working. At first, a 405 Method Not Allowed was being returned. I placed the service within an Umbraco site so I just figured that was where the conflict was.

After some digging around on the internet, I came across across ASP.NET MVC got 405 error on HTTP DELETE request?, from Stack Overflow, which it stated that the issue was related to WebDAV. The solution was to remove the WebDAVModule. That got rid of the 405, but unfortunately didn’t resolve the issue.

The requests started returning a 200 status code, which was good, but the page that was coming back was a 500 error. Because I wasn’t testing the service on the actual machine, I wasn’t seeing the actual error. So I logged on to the server and the tests showed the following error:

HTTP Error 500.21 – Internal Server Error
Handler “WebDAV” has a bad module “WebDAVModule” in its module list

(Gotta’ love more detailed errors.) From there I found How can I get OData DELETE to work?, also from Stack Overflow, which gave a good explanation of what was happening and how to solve it. Apparently, WebDAV blocks the DELETE and PUT requests (thanks a lot WebDAV…) and so the solution is to remove WebDAV or disable it on your site. You can completely disable WebDAV as follows:

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

Thank you to Stack Overflow and all those that contribute to it!

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s