Binding IIS Express to an IP Address [duplicate]
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.
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
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.
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
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" />
Change bindingInformation=":8080:"
And remember to turn off the firewall for IISExpress
精彩评论