2

I've been trying to run a node application on iisnode. this app runs on node.js smoothly and has no problem. however, i need to integrate this app to an asp.net application hence i've been trying to run this app on iis using iisnode! but i've been facing some difficulties! i was wondering is there anything that need to be changed in config or server.js file to make it work ?

thanks !

Poorya
  • 1,291
  • 6
  • 27
  • 57

1 Answers1

1

The only required change in node app will be port number - use process.env.PORT value instead of specific numeric in you server.js/app.js as stated in the official /src/samples/express/hello.js (notice the last line):

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);

Also make sure that asp.net's web.config have sections for node (taken from /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>
Sevenate
  • 6,221
  • 3
  • 49
  • 75