Iisnode - IIS7.5: 405 Method not allowed when executing PUT request

I started experimenting with iisnode and expressjs to create a REST API with node.

So, on server.js server, I created something like

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

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

Any idea on how to solve this?

By the way, I already googled and tried to add PUT verbs here and there in different Handler mappings without success ...

+6
source share
2 answers

Now I finally found a solution to this problem, namely: WebDavModule blocked my PUT requests.

To fix the problem:

  • Open IIS Manager
  • Go to your application configuration and open "Modules"
  • Find WebDavModule and delete it (menu on the right)

Then he worked for me.

Alternatively, in your web.config application add

 <system.webServer> ... <modules> <remove name="WebDAVModule"/> </modules> </system.webServer> 
+21
source

One of the reasons may be that your web.config does not display the specific request you make to the iisnode handler. In this case, the request is captured by the static request handler, which does not support PUT methods and responds with 405.

To fix this, you need to register an iisnode handler 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 a URL that does not end with the name of your node.js file (for example, it looks like it is), you will need to use the URL rewrite module to specify exactly IIS in requests which URLs should be rewritten to specify the URL of your node.js. entry point More details: http://tomasz.janczuk.org/2011/08/using-url-rewriting-with-nodejs.html

+2
source

Source: https://habr.com/ru/post/911845/


All Articles