Can't access Visual Studio project from IP, on

2019-02-21 14:37发布

问题:

I'm running a project in visual studio. I hit run and it launches IE pointing at http://localhost:1267

If I try to visit http://10.211.55.3:1267 (the machine's IP), I get nothing, even when visiting from the same machine. IIS7 works fine.

The machine is actually a VM running in parallels.

Any ideas what's may be going on?

回答1:

If you are using the Visual Studio Development Server (and not IIS,) your server will only bind to localhost. You can not use another IP address to access it. If you must, you can work around this with proxies.

If you are running IIS, make sure that your web server is binding to all addresses (0.0.0.0)



回答2:

CygWin Solution (no proxy install needed)

ssh USER@OTHER_HOST -R IIS_PORT:localhost:IIS_PORT

replace USER, OTHER_HOST and IIS_PORT. Now you can browse with your OTHER_HOST to the testpage on localhost:IIS_PORT. This enables you the ability to test your stuff on remote Linux hosts (for example).



回答3:

For IIS Express, you need to grant yourself permission to bind to network adapters other than localhost, and configure IIS express to bind to all adapters. If you desire access from another computer, you need to also open the port on your firewall. This answer details these steps.



回答4:

To do this you need to edit applicationhost.config file manually

<bindings>
   <binding protocol="http" bindingInformation="*:57177:localhost" />
   <binding protocol="http" bindingInformation="*:57177:127.0.0.1" />
</bindings>

Aplication will be accessible on:

localhost:57177
127.0.0.1:57177

If you want remote access, I think adding your IP address and disabling firewall will do it.