I'm .Net developer and new bie to Node.js application. I was trying to create a proxy layer for my ASP.NET MVC application through Node.js to do cross domain communication without touching the server level configuration of my ASP.NET WebAPI.
Lets start from code to quickly understand my questions,
I have created a single MVC application that holds my Node under "MyApp/app.js" and ASP.NET MVC view that will make an AJAX call to my Node file.
<h2>This is an Index page</h2>
<script>
$(function () {
$.ajax({
url: "/sample",
success: function () {
alert('Done');
}
});
});
</script>
Below is my web.config,
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="MyApp/app.js" verb="*" modules="iisnode" />
</handlers>
Here is my app.js,
var express = require('express');
var app = express();
app.set('port', process.env.PORT || 3000);//When I hardcode to Port:80 I'm getting "Error: listen EACCES 0.0.0.0:80"
app.listen(app.get('port'), function () {
console.log('Express up and listening on port' + app.get('port'));
});
app.get('/Sample', function (req, res) {
res.send('Hello World Sample!');
});
When I try to open my view, the AJAX call was failing with "404 error". I tried to run my Node app in port :80 but it throws err "Error: listen EACCES 0.0.0.0:80". Why can't I run my Node app and ASP.NET MVC view on same port?