我想用asp.net mvc运行node.js来执行socket.io操作。
我已成功将node.js包含在asp.net mvc中,如here
中所述我的问题是如何在asp.net mvc中运行express.js,
我在Global.asax.cs文件中执行了网址重写,如
void Application_BeginRequest(object sender,EventArgs e)
{
//获取当前路径
string CurrentPath = Request.Path.ToLower();
if(CurrentPath.StartsWith(“/ node”))
{HttpContext MyContext = HttpContext.Current;
MyContext.RewritePath( “/节点/ index.js /”);
}
}
所以在url http:localhost:1234 / node 应该将我重定向到Node文件夹中的index.js文件
一切运转良好,但是,
当我开始在index.js中加入express.js服务器,如
var express = require('express');
var app = express.createServer();
app.get('/ node /',function(req,res){
res.send('welcome to express');
});
app.listen(process.env.PORT);
我收到错误无法获取/Node/index.js /
我在IIS 7 Express系统的Windows 7 32位系统中运行此应用程序,并且已安装的节点版本为
iisnode.js - iisnode-full-iis7-v0.2.3-x86
node.js - node-v0.8.19-x86
谢谢。
答案 0 :(得分:0)
你有一个iisnode处理index.js的web.config条目吗?
默认情况下,iisnode未设置为.js处理程序,因为客户端javascript远远多于服务器端javascript,因此您需要明确打开iisnode作为该文件的处理程序。