所以,这是我的情况。这是我第一次在Windows中部署节点应用程序。所以,到目前为止,我一直很沮丧。问题是路由网址。我编写了一个非常简单的测试应用程序,并希望在IIS节点中部署后在Windows中对其进行测试。但由于某种原因,我一直得到这个错误“无法获取(无论我输入什么)” 这是我到目前为止所尝试的 web.config文件 -
<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:
-->
<rewrite>
<rules>
<rule name="myapp">
<match url="myapp/*" />
<action type="Rewrite" url="hello.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
服务器文件(hello.js) -
var express = require('express');
var app = express.createServer();
app.get('/myapp/foo', function (req, res) {
res.send('Hello from foo! [express sample]');
});
app.get('/myapp/bar', function (req, res) {
res.send('Hello from bar! [express sample]');
});
app.listen(process.env.PORT);
尝试之后 - 这就是我得到的
1. http://localhost:4500/node/TestApp/myapp/foo
- “无法GET / node / TestApp / myapp / foo”
2. http://localhost:4500/node/TestApp/myapp
- “无法GET / node / TestApp / myapp”
请帮我摆脱这个烂摊子。