November 27, 2009 21:11 by
admin
I have been doing most of my ASP.Net MVC RESTful web service development on IIS6 or IIS7. Recently however, I tried it on Windows 7 RTM using IIS7.5. Using the “Classic .Net AppPool” everything worked great. Then I tried the “DefaultAppPool” (i.e. using Integrated Mode). Everything seemed fine… until I wanted to PUT a new resource and DELETE a resource.
Without even going near my code, IIS reported back:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Detailed Error Information
| Module | WebDAVModule |
| Notification | MapRequestHandler |
| Handler | WebDAV |
| Error Code | 0x00000000 |
| Requested URL | http://localhost:80/RESTfulMVCWebService/Version19/UrlRouting.axd?format=xml |
| Physical Path | C:\Projects\RESTfulMVCWebService\Version19\WebService\UrlRouting.axd |
| Logon Method | Anonymous |
| Logon User | Anonymous |
Certainly not what I had expected! I turned on tracing to try and understand what was happening… and just as it says in the message, it appears that the UrlRoutingModule has taken the requested URL and re-pointed to UrlRouting.axd. Then the WebDAVModule decides that PUT is not allowed for this URL.
I wasted a fair amount of time looking at the Handler Mappings configuration trying to get HTTP PUT to be accepted. I removed the WebDAV handler. I added a catch all handler etc. etc. I tried enabling WebDAV, I tried disabling it. I tried giving “Everyone” read write access to directory containing the web service. Nothing seemed to work.
Really I should have looked more closely at the error message. I was looking at Handler Mappings, but the error was with the Modules. As soon as I removed the WebDAVModule, everything worked as it should. I made the change through the Internet Information Services (IIS) Manager, but I could have made the change manually in the web.config. All that was needed was to add the following:
<system.webServer>
<modules … >
<remove name="WebDAVModule" />
……
</modules>
So why had I not seen this before when I worked with HTTP PUT? Well, previously I was using IIS7.0 (I developed on Vista) or IIS6 (when deploying to Windows Server 2003). These versions of IIS did not have WebDAV installed by default. When I was presented with a fresh install of Windows 7, it was already installed.
So… one to watch out for if you want to use IIS 7.5 to implement RESTful web services!
7639b052-6c4c-4213-874e-37f12c466b4d|10|4.1