DiscountASP.NET

Getting started with Node.js

Node.js is a new interpreter that allows JavaScript to be processed on the server side.  It is installed and enabled (as a beta service) on the DiscountASP.NET web servers.  To gain the full use of node.js, all you need to do is setup the Handler Mapping to route all .js file extensions to the Node.js interpreter.  This has to be done within the applications web.config file.

There are two ways to do this.  The easiest way is through IIS 7 Manager.  You can use this Knowledge Base article for details on how to connect to our web server with IIS 7 Manager.

Once connected, go to the “Handler Mapping” module.  Click on “Add Module Mapping.

Enter the settings as you see them.  Now you have your application set to push all *.js files to Node.js.

You do not have to use IIS 7 Manager to create this mapping.  You can directly code it within your application’s web.config file.  What you will need to look for is the ‘system.webserver’ element within the configuration of the web.config file and add the handler line:

<configuration>
  <system.webServer>
    <handlers>
    <add name="iisnode" path="*.js" verb="*" modules="iisnode" />
    </handlers>
  </system.webServer>
</configuration>

One of the things you will need to be aware of is that all *.js files will be processed by the node.js engine.  The side effect of that is some of the JavaScript on your pages may not function correctly because they are no longer being sent to the client’s browser for processing.  I tested an HTML5 page which uses a lot of JavaScript and some of the features in the HTML5 page did not work.

There are a couple of work-arounds to this:

1. Upload the .js file you want to be processed by node.js to its own subfolder.  Then add the web.config setting to that folder.

2. You can specify which .js file gets processed by the node.js engine.  In the path field, rather than implementing a wild card, you can set: path=”somefile.js”.

Exit mobile version