简体   繁体   English

IISNode网站列出文件夹而不是启动server.js

[英]IISNode site lists folder rather than starting server.js

I am struggling to get IISNode to serve the main server.js application file for my node application by default, at the moment if I browse to http://localhost:80/ where my app is running it simply lists the folder contents of the app. 在默认情况下,如果我浏览到运行我的应用程序的http:// localhost:80 / ,我正在努力使IISNode为节点应用程序提供主server.js应用程序文件,但它只是列出了文件夹的内容。应用程序。 Although it does run the server.js file if I click on it. 尽管单击它确实会运行server.js文件。

Obviously this is not working for me as the Node app is a web api which I need to be able to hit via http. 显然,这对我来说不起作用,因为Node应用程序是一个Web API,我需要能够通过http进行点击。

This is the line inside my web.config indicating server.js as the entry point. 这是我的web.config内部的行,指示server.js作为入口点。

Could anyone point me to something I'm missing? 有人可以指出我想念的东西吗?

This is because you don't have the URL Re-write Module for IIS installed where you are running IIS. 这是因为您没有在运行IIS的位置安装IISURL重写模块

Without URL Rewriting in your Web.config you will need to navigate to http://localhost:80/server.js/whatever-route . 在Web.config中没有URL重写的情况下,您将需要导航到http://localhost:80/server.js/whatever-route Obviously this isn't feasible in a production environment. 显然,这在生产环境中是不可行的。

If you need a jump start I have a template Web.config that I use for all of my Node.js services here . 如果需要快速入门,我这里有一个模板Web.config,可用于所有Node.js服务。 It has all the URL Rewriting necessary to get your app up and running and then some additional stuff (Virtual Directory Support and Socket.io Support). 它具有启动应用程序并运行所需的所有URL重写,以及其他一些内容(虚拟目录支持和Socket.io支持)。 Just make sure that you change the main file to match the one that your app uses. 只需确保您更改主文件以匹配您的应用程序使用的文件即可。 The default main file in the above template Web.config is app.js. 上面的模板Web.config中的默认主文件是app.js。 From the sounds of it you'll probably want to change this to server.js. 从听起来,您可能希望将其更改为server.js。 You'll need to change this line and this line . 您需要更改此行此行 If you plan on using Socket.io you'll also need to change this line . 如果您打算使用Socket.io,则还需要更改此行

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM