将 IIS Express 绑定到 IP 地址

发布于 2024-10-15 11:46:34 字数 74 浏览 2 评论 0原文

是否可以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

笑着哭最痛 2024-10-22 11:46:34

我想你可以。

为此,您需要编辑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

稀香 2024-10-22 11:46:34

为了让 IIS Express 对任何 IP 地址做出响应,只需将该地址留空即可,即:

bindingInformation=":8080:"

在进行更改之前,不要忘记重新启动 IIS Express。

In order for IIS Express answer on any IP address, just leave the address blank, i.e:

bindingInformation=":8080:"

Don't forget to restart the IIS express before the changes can take place.

简单 2024-10-22 11:46:34

如上所述,编辑应用程序 host.config。找到这一点的一个简单方法是使用 IIS Express 在 VS 中运行您的站点。右键单击系统托盘图标,显示所有应用程序。选择您的站点,然后单击底部的配置链接将其打开。

我建议添加另一个绑定条目,并将最初的本地主机保留在那里。此附加绑定将作为站点下的单独应用程序出现在 IIS Express 系统托盘中。

为了避免必须以管理员身份运行 VS(有很多不以管理员身份运行的充分理由),请添加如下 netsh 规则(显然用您的值替换 IP 和端口) - 为此,您需要一个 admin cmd.exe,它只需要运行一次:

netsh http add urlacl url=http://192.168.1.121:51652/ user=\Everyone

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 http add urlacl url=http://192.168.1.121:51652/ user=\Everyone

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 with netsh http delete urlacl url=blah.

Further info: http://msdn.microsoft.com/en-us/library/ms733768.aspx

小嗷兮 2024-10-22 11:46:34

以下是使用 IIS Express 运行 x64 位 IIS 应用程序所需进行的完整更改,以便远程主机可以访问它:

iisexpress /config:"C:\Users\test-user\Documents\IISExpress\config\applicationhost.config" /site:MyWebSite
Starting IIS Express ...
Successfully registered URL "http://192.168.2.133:8080/" for site "MyWebSite" application "/"
Registration completed for site "MyWebSite"
IIS Express is running.
Enter 'Q' to stop IIS Express

配置文件 (applicationhost.config) 添加了一个部分,如下所示:

<sites>
  <site name="MyWebsite" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\build\trunk\MyWebsite" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation=":8080:192.168.2.133" />
    </bindings>
  </site>

64 位版本.NET 框架可以按如下方式启用:

<globalModules>
    <!--
        <add name="ManagedEngine" image="%windir%\Microsoft.NET\Framework\v2.0.50727\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness32" />
        <add name="ManagedEngineV4.0_32bit" image="%windir%\Microsoft.NET\Framework\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness32" />
    -->             
    <add name="ManagedEngine64" image="%windir%\Microsoft.NET\Framework64\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness64" />

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:

iisexpress /config:"C:\Users\test-user\Documents\IISExpress\config\applicationhost.config" /site:MyWebSite
Starting IIS Express ...
Successfully registered URL "http://192.168.2.133:8080/" for site "MyWebSite" application "/"
Registration completed for site "MyWebSite"
IIS Express is running.
Enter 'Q' to stop IIS Express

The configuration file (applicationhost.config) had a section added as follows:

<sites>
  <site name="MyWebsite" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\build\trunk\MyWebsite" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation=":8080:192.168.2.133" />
    </bindings>
  </site>

The 64 bit version of the .NET framework can be enabled as follows:

<globalModules>
    <!--
        <add name="ManagedEngine" image="%windir%\Microsoft.NET\Framework\v2.0.50727\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness32" />
        <add name="ManagedEngineV4.0_32bit" image="%windir%\Microsoft.NET\Framework\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness32" />
    -->             
    <add name="ManagedEngine64" image="%windir%\Microsoft.NET\Framework64\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness64" />
对岸观火 2024-10-22 11:46:34

更改 bindingInformation=":8080:"

并记得关闭 IISExpress 的防火墙

Change bindingInformation=":8080:"

And remember to turn off the firewall for IISExpress

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文