Can't connect to IIS Express using IP Address

自古美人都是妖i 提交于 2021-02-07 10:48:55

问题


From what I understand, VS2012 comes with the IIS Express version by default. And it allows you to connect to the development site using IP address. Currently I can connect using http://localhost:22222. But this would not connect using this http://xxx.xxx.xxx.xxx:22222 where xxx just a local IP of the development machine . I have verified that the IIS Express is running and being used. The IE error was http 400 bad request.


回答1:


I know you have asked question since a long time. I have an answer to this question at this link.

Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:

<bindings>
      <binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>

Before you do this , you will have to register this IP address using netsh command as below:

If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:

> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone

This just tells http.sys that it’s ok to talk to this url.

> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow

This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.

Note: Be sure to change the bindings of your project only by locationg its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using the given IP address.




回答2:


The solution that worked for me was this one:

The one thing that fixed this for me was using the following line in the <bindings> section for my site in the applicationhost.config file:

<bindings>
    <binding protocol="http" bindingInformation="*:8099:" />
</bindings>

The key was to simply remove localhost. Don't replace it with an asterisk, don't replace it with an IP or a computer name. Just leave it blank after the colon.

After doing this, I don't need to run Visual Studio as administrator, and I can freely change the Project Url in the project properties to the local IP or computer name. I then set up port forwarding and it was accessible to the Internet.

EDIT:

I've discovered one more quirk that is important to getting IIS Express to properly serve external requests.

If you are running Visual Studio/IIS Express as an administrator, you must not add a reservation to HTTP.SYS using the "netsh http add urlacl ..." command. Doing so will cause an HTTP 503 Service Unavailable error. Delete any reservations you've made in the URLACL to fix this.

If you are not running Visual Studio/IIS Express as an administrator, you must add a reservation to the URLACL.



来源:https://stackoverflow.com/questions/14042271/cant-connect-to-iis-express-using-ip-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!