When you use PUT in your Nancy application and you host your application on an IIS 7 server then you might get a 405 error (Method not allowed).

The solution to this problem is very simple but I will put it here for me.

The problem is that you might have the webdavmodule installed on your IIS and that is gobbling up all the PUT requests.

So the simple solution is to remove the webdavmodule.

You can do this via the IIS manager and just remove it from your site, but if you use webdeploy it will add it back in the next time you deploy.

So it is better to use the webconfig to tell IIS you really don’t want it for your particular site.

So you add this to the web.config

XML
1
2
3
4
5
<system.webServer>
    <modules>
       <remove name="WebDAVModule"/>
    </modules>
</system.webServer>
<system.webServer>
    <modules>
       <remove name="WebDAVModule"/>
    </modules>
</system.webServer>

Simple, and it works. Let’s move on.

No TDD was involved in the making of this blogpost.