Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iisnode - IIS7.5: 405 Method not allowed when performing PUT request

I started to do some experimentation with iisnode and expressjs to create a REST like API with node.

So on the server.js I created something like

app.put("/test", function(req, res){
    ...
});

However, when I execute the PUT request I get a 405 Method not allowed from the IIS 7.5 installation.

Any idea on how to solve this?

BTW, I googled already and tried to add the PUT verbs here and there in the different Handler Mappings with no success...

like image 770
Juri Avatar asked Mar 28 '12 09:03

Juri


People also ask

How do I fix the 405 method not allowed error in IIS?

If you don't need to use WebDAV, then the easiest and the best way to fix "405 method not allowed" issue is to remove WebDAV from your system. You can easily get this done in "Turn Windows Features On or Off" simply un-ticking the checkbox.


2 Answers

I now finally found the solution to this problem namely the WebDavModule was blocking my PUT requests.

To resolve the issue:

  1. Open your IIS Manager
  2. Goto your application configuration and open "Modules"
  3. Search WebDavModule and remove it (menu on the right)

It then worked for me.

Alternatively, in your application's web.config add

<system.webServer>
    ...
    <modules>
       <remove name="WebDAVModule"/>
    </modules>
</system.webServer>
like image 170
Juri Avatar answered Sep 18 '22 13:09

Juri


One reason may be that your web.config does not map the particular request you are making to the iisnode handler. In that case the request is picked up by the static request handler which does not support PUT methods and responds with a 405.

To fix this you need a iisnode handler registration like this in your web.config: https://github.com/tjanczuk/iisnode/blob/master/src/samples/helloworld/web.config#L7

In addition, if you plan to use URL that do not end with the name of your node.js file (like seems to be the case above), you will need to use a URL rewrite module to tell IIS exactly which requests should have their URLs rewritten to point to the URL of your node.js entry point. Read more at: http://tomasz.janczuk.org/2011/08/using-url-rewriting-with-nodejs.html

like image 40
Tomasz Janczuk Avatar answered Sep 21 '22 13:09

Tomasz Janczuk