iisnode不会运行Express

我试图运行使用iisnode快递。 我遵循了所提供的示例,但是当尝试使用最新的Express版本和基本示例时,无法使其工作。

我得到的错误Cannot GET /node/parislight/hello.js和其他时间,只是一个The webpage cannot be found

我创build了一个hello.js文件(主要快速文件)从快速文档取自。

 var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Hello World!') }) var server = app.listen(process.env.PORT, function () { var host = server.address().address var port = server.address().port console.log('Example app listening at http://%s:%s', host, port) }) 

我添加了必要的web.config文件(从iisnode中的快速示例中提取)

 <configuration> <system.webServer> <!-- indicates that the hello.js file is a node.js application to be handled by the iisnode module --> <handlers> <add name="iisnode" path="hello.js" verb="*" modules="iisnode" /> </handlers> <!-- use URL rewriting to redirect the entire branch of the URL namespace to hello.js node.js application; for example, the following URLs will all be handled by hello.js: http://localhost/node/express/myapp/foo http://localhost/node/express/myapp/bar --> <rewrite> <rules> <rule name="myapp"> <match url="myapp/*" /> <action type="Rewrite" url="hello.js" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 

我给IIS中使用的应用程序池提供了所有必要的权限。

你可以在文件末尾使用catch all函数来获取任何url,并发送一个200响应或者发送你特殊的404页面。 注意:展示位置必须位于所有其他指定的url之后。

 app.get('*', function (req, res) { res.send('Hello World!') }) 

它需要使用完整的path:

app.get调用中指定的path必须是请求的完整path。

资源

现在看起来像这样:

 app.get('/node/parislight/myapp/demo', function (req, res) { res.send('Hello World!') }) 

通过以下方式join:

HTTP://本地主机/节点/ parislight / MYAPP /演示