1

The first question I have is, is it possible to use Node.JS and Socket.IO inside of a ASP.NET webform and .Net web application?

What I am trying to do is show real-time data, and I want to do this using node.js modules.

I understand the client side code for node.js but how do I implement the server side, i.e. exactly where do the server side code go and how do i call it?

here is what i have so far: myfiddle

<head runat="server">
<title>Logger</title>
  <script src="/assets/js/chosen.jquery.min.js"></script>
<script src="/assets/js/date-time/bootstrap-datepicker.min.js"></script>
 <script src="/Scripts/js-cookie.js"></script>
<script src="/Scripts/socket.io-1.3.5.js"></script>
<script src="/Scripts/displaylogs.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="container">

</div>
</form>
</body>


$(document).ready(function () {
// start by the connection with socket.io
var socket = io.connect('http://localhost:8080');
var container = $('#container');

// makes every new chunk of data it receives displayed inside a div.
socket.on('new-data', function(data) {

    var newItem = $('<div>' + data.value + '</div>');

    container.append(newItem);
});
});
1

1 Answer 1

0

It's definitely possible to use node in a .NET app. You have to configure IIS to route requests to the node process when a node file is requested. The best way is usually to put all your node code in a subdirectory just for node and let IIS route all requests for that subdirectory to the node process.

Take a look at IISNode. It's the same IIS extension they use on Windows Azure.

Sign up to request clarification or add additional context in comments.

3 Comments

the problem is that I am not hosting with IIS. I am letting a third party handle the server, specifically rackspace and amazon.
is it possible to spin up a node.js server on the client?
If you don't have access to the server's IIS instance then you'll need to get in touch with your host and see if they are able to provide node support for you. No it is not possible to spin up a node server on the client. Node is a program you install and run just like IIS or Apache is. Unlike .NET where IIS is the server and routes requests to ASP.NET for processing the .NET code, node is the equivalent of both IIS and the ASP.NET runtime combined. The node process contains both the JavaScript engine and the necessary bits to host your app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.