将IIS Express绑定到IP地址

jdi*_*iaz 106 asp.net iis-express

是否可以使用IIS Express来托管网络上的页面.开箱即用它可以做localhost但我试图将它绑定到IP地址.

vik*_*all 107

我想你可以.

为此,您需要applicationhost.config手动编辑文件(编辑bindingInformation' <ip-address>:<port>:<host-name>')

要启动iisexpress,您需要管理员权限

  • 2015年可视化工作室更新:在Visual Studio 2015中,IIS Express配置文件已移动.它们现在按项目分开,存储在/ {project folder} /.vs/config/applicationhost.config http://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-远程计算机 (35认同)
  • 这个信息很棒:谢谢.我学到了很难将IIS打开到外部流量(而不是localhost),您需要以管理员身份运行.(我在我的局域网上测试平板电脑).如果您在Visual Studio中工作,请以管理员身份运行,以便访问权限扩展到其子流程.这将打开IISExpress以绑定到localhost以外的其他东西.`<binding protocol ="http"bindingInformation ="*:8081:localhost"/> <binding protocol ="http"bindingInformation ="*:8083:192.168.2.102"/>` (31认同)
  • 自我注意:如果您拒绝访问,**以管理员身份运行Visual Studio**. (19认同)
  • VISUAL STUDIO 2017 至 2019 的更新:文件已从“/{项目文件夹}/.vs/config/applicationhost.config”移动到“/{项目文件夹}/.vs/{解决方案名称}/config/applicationhost”。配置`。我遇到了支持两个版本vs的问题,忘记修改正确的配置 (6认同)
  • 就是这样.复制applicationhost.config并将绑定修改为<bindings> <binding protocol ="http"bindingInformation =":8080:<ip address>"/> </ bindings> (3认同)
  • 我有同样的问题.我根据您的建议更改了绑定信息,并重新启动了iis express.当我从Visual Studio启动我的Web项目时,它仍然会转到http:// localhost:yyyy./xxxx.有任何想法吗? (3认同)
  • 仅供参考,在@ShaneCastle的帮助下,找到我的applicationhost.config文件,我单击系统任务栏箭头以找到IIS Express任务栏图标,右键单击并单击“显示所有应用程序”,我的作为列表中的单个条目运行。左键单击“应用程序名称”字段会在同一对话框中显示一个额外的信息面板,其中包含applicationhost.config的路径。左键单击config文件路径在VS中将其打开以进行编辑。 (2认同)

小智 87

为了让IIS Express能够接听任何IP地址,只需将地址留空,即:

bindingInformation=":8080:"
Run Code Online (Sandbox Code Playgroud)

在发生更改之前,请不要忘记重新启动IIS Express.

  • IIS Express必须以管理员身份运行才能绑定到除"localhost"之外的任何内容.如果从`VS 2010`启动,以管理员身份运行`VS 2010`. (32认同)
  • 自我注意:如果您拒绝访问,**以管理员身份运行Visual Studio**. (5认同)
  • 确保以管理员身份运行Visual Studio并设置`bindingInformation =":8080:"`not`bindingInformation ="*:8080:*"`在重启Visual Studio后停止Visual Studio编写新的`<site>`条目 (5认同)
  • 只是为了增加像我一样遭受3个小时痛苦的人们,`applicationhost.conifg`文件中有许多`bindinginformation`属性,请选择属于您站点的属性! (3认同)
  • 我尝试这样做-但是当我转到http://192.168.1.10:55870/时,它会自动将我重定向到http:// localhost / (2认同)
  • 这个解决方法对我来说很有效`bindingInformation=":8080:"`。出于某种原因,`*8080*` 不适用于 .NET Core Web 应用程序。不要忘记运行 `netsh: netsh http add urlacl url=http://*:8080/ user=\Everyone` 以避免以管理员身份运行 VS 并在 Windows 防火墙或应用程序中为此端口添加防火墙规则管理防火墙设置。 (2认同)

Dav*_*row 35

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

我建议添加另一个绑定条目,并将初始localhost保留在那里.此附加绑定将作为站点下的单独应用程序显示在IIS Express系统中.

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

netsh http add urlacl url=http://192.168.1.121:51652/ user=\Everyone
Run Code Online (Sandbox Code Playgroud)

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

  • Tnx提到如何查找配置文件 (4认同)
  • 我已经成功使用 `netsh http add urlacl url=http://*:10368/ user=everyone` 和 `&lt;binding protocol="http" bindingInformation=":10368:" /&gt;` (使用“*”而不是“+”)。这将使 IIS Express 能够绑定到所有可用的 IP 地址。 (2认同)

Tho*_*att 11

以下是使用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
Run Code Online (Sandbox Code Playgroud)

配置文件(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>
Run Code Online (Sandbox Code Playgroud)

可以按如下方式启用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" />
Run Code Online (Sandbox Code Playgroud)


Ha *_*oan 8

更改 bindingInformation=":8080:"

并记得关闭IISExpress的防火墙