将 IIS Express 绑定到 IP 地址
是否可以使用 IIS Express 在网络上托管页面。开箱即用,它可以执行 localhost,但我正在尝试将其绑定到 IP 地址。
Is it possible to use IIS Express to host pages on a network. Out of the box it can do localhost but I am trying to bind it to an IP address.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想你可以。
为此,您需要编辑
applicationhost。手动编辑 config
文件(编辑 bindingInformation '::
')要启动 iisexpress,您需要管理员权限
I think you can.
To do this you need to edit
applicationhost.config
file manually (edit bindingInformation '<ip-address>:<port>:<host-name>
')To start iisexpress, you need administrator privileges
为了让 IIS Express 对任何 IP 地址做出响应,只需将该地址留空即可,即:
在进行更改之前,不要忘记重新启动 IIS Express。
In order for IIS Express answer on any IP address, just leave the address blank, i.e:
Don't forget to restart the IIS express before the changes can take place.
如上所述,编辑应用程序 host.config。找到这一点的一个简单方法是使用 IIS Express 在 VS 中运行您的站点。右键单击系统托盘图标,显示所有应用程序。选择您的站点,然后单击底部的配置链接将其打开。
我建议添加另一个绑定条目,并将最初的本地主机保留在那里。此附加绑定将作为站点下的单独应用程序出现在 IIS Express 系统托盘中。
为了避免必须以管理员身份运行 VS(有很多不以管理员身份运行的充分理由),请添加如下 netsh 规则(显然用您的值替换 IP 和端口) - 为此,您需要一个 admin cmd.exe,它只需要运行一次:
netsh 可以添加像 url=http://+:51652/ 这样的规则,但我失败了让它与 IIS Express 很好地结合在一起。您可以使用
netsh http show urlacl
列出现有规则,并可以使用netsh http delete urlacl url=blah
删除它们。更多信息:http://msdn.microsoft.com/en-us/library/ ms733768.aspx
As mentioned above, edit the application host.config. An easy way to find this is run your site in VS using IIS Express. Right click the systray icon, show all applications. Choose your site, and then click on the config link at the bottom to open it.
I'd suggest adding another binding entry, and leave the initial localhost one there. This additional binding will appear in the IIS Express systray as a separate application under the site.
To avoid having to run VS as admin (lots of good reasons not to run as admin), add a netsh rule as follows (obviously replacing the IP and port with your values) - you'll need an admin cmd.exe for this, it only needs to be run once:
netsh can add rules like url=http://+:51652/ but I failed to get this to place nicely with IIS Express. You can use
netsh http show urlacl
to list existing rules, and they can be deleted withnetsh http delete urlacl url=blah
.Further info: http://msdn.microsoft.com/en-us/library/ms733768.aspx
以下是使用 IIS Express 运行 x64 位 IIS 应用程序所需进行的完整更改,以便远程主机可以访问它:
配置文件 (applicationhost.config) 添加了一个部分,如下所示:
64 位版本.NET 框架可以按如下方式启用:
Below are the complete changes I needed to make to run my x64 bit IIS application using IIS Express, so that it was accessible to a remote host:
The configuration file (applicationhost.config) had a section added as follows:
The 64 bit version of the .NET framework can be enabled as follows:
更改
bindingInformation=":8080:"
并记得关闭 IISExpress 的防火墙
Change
bindingInformation=":8080:"
And remember to turn off the firewall for IISExpress