Friday, July 04, 2014

IIS 8 - Get 405 (Method Not Allowed) on DELETE

Symptom


You have implemented an Web API interface (in my case Web API 2) for Delete operation. Your GETs as well as POST works, but when you try to execute DELETE, you get a 405 error code.

DELETE http://localhost/MySite/MyApp 405 (Method Not Allowed)

What Worked For Me


Since I have explicitly set up my environment not to get into CORS situation, it was clear to me that something else was an issue. However, if you are using the built-in IIS from the Visual Studio to test your interface, it will come with a special port number and it is highly likely that you are running into the CORS situation so be sure to check that as well.

What fixed was to modify a part of the web.config file in the following manner.


By removing ExtensionlessUrlHandler-ISAPI-4.0_64bit, it started to work.

The Microsoft KB Article http://support.microsoft.com/kb/224609 was most helpful in deriving this solution for me.

According to the above article, the configuration catches "like" configurations first and thus by the time it is at your level of web application, the configuration is basically "messed up."


Side Note


Also, I did not have a proper configuration on my web interface declaration and after above issue was fixed I was starting to get an error code 500. This goes to say that if you get the error 500, the DELETE is trying to execute and you are out of the web.config issue.

In my case, I forgot to add "{id}" in my Route declaration.

      [Route("{id}")]
        [HttpDelete]
        public void Delete(Guid id)
        {


Post a Comment