8

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...

Community
  • 1
  • 1
Juri
  • 32,424
  • 20
  • 102
  • 136
  • It's 99% sure something in IIS so I am pretty sure you missed something there. However, I can't really look in your IIS config :-) – Jan Jongboom Mar 28 '12 at 15:14
  • This is why I just can't understand why anyone but a masochist would want to use IIS to host node... – UpTheCreek Mar 29 '12 at 07:14
  • :) I guess it's just because of the deployment environment you're in. You may have the restrictions to just run IIS webservers...in my case 'cause I'd like to deploy it to AppHarbor as it is more suitable (from a cost point of view) for my experiments (than Heroku for instance). – Juri Mar 29 '12 at 07:48

2 Answers2

24

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>
Juri
  • 32,424
  • 20
  • 102
  • 136
3

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

Tomasz Janczuk
  • 3,220
  • 21
  • 19
  • Thx for your answer, however I already found your blog posts and configured my app accordingly...without any success. I've found the solution now, though. (see below) – Juri Mar 29 '12 at 07:06