将IIS Express绑定到IP地址

时间:2011-02-01 18:37:10

标签: asp.net iis-express

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

5 个答案:

答案 0 :(得分:102)

我想你可以。

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

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

答案 1 :(得分:85)

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

bindingInformation=":8080:"

不要忘记在发生更改之前重新启动IIS express。

答案 2 :(得分:30)

如上所述,编辑应用程序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

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

答案 3 :(得分: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

配置文件(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" />

答案 4 :(得分:8)

更改bindingInformation=":8080:"

请记得关闭IISExpress的防火墙

相关问题