当从node.js切换到iisnode时,有什么改变?

我一直在尝试在iisnode上运行节点应用程序。 这个应用程序运行在node.js顺利,没有问题。 但是,我需要将此应用程序集成到一个asp.net应用程序,因此我一直在尝试使用iisnode在iis上运行此应用程序! 但我一直面临一些困难! 我想知道是否有什么需要改变在config或server.js文件,使其工作?

谢谢 !

节点应用程序中唯一需要的更改将是端口号 – 在官方的/src/samples/express/hello.js中指出,在server.js / app.js中使用process.env.PORT值而不是特定的数字(请注意最后一行):

 var express = require('express'); var app = express.createServer(); app.get('/node/express/myapp/foo', function (req, res) { res.send('Hello from foo! [express sample]'); }); app.get('/node/express/myapp/bar', function (req, res) { res.send('Hello from bar! [express sample]'); }); app.listen(process.env.PORT); 

还要确保asp.net的web.config有节点部分(取自/src/samples/express/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: 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>