Access localhost on the main machine from VMware Workstation 8 for ASP.NET development test

ahmd0 picture ahmd0 · Apr 15, 2012 · Viewed 23.4k times · Source

I run an ASP.NET Development Server (that came with MS Visual Studio 2010) on my Windows 7 machine. I'm currently developing an ASP.NET C# web application and to test it on Windows 7 machine I need to navigate my web browser to an address like this:

http://localhost:59215/Default.aspx

I also have the VMware Workstation 8 installed on that Windows 7 with other OS as virtual machines. I need to try to load my web app from those virtual machines, but when I type the above address there I get "Cannot display page" error in a browser. Note that I can access internet from a virtual machine itself, but for some reason localhost on the main machine is not accessible.

Any ideas how to set this up?

Answer

ahmd0 picture ahmd0 · Apr 15, 2012

OK, I got it!

For those who're interested, here's how:

Say, my developement URL on the host computer is: http://localhost:59215/Default.aspx

Download this util, called tcpTrace and run it on a host machine. When it starts configure it as follows:

Listen to port #: 80
Destination Server: localhost
Destination Port #: 59215 (which will be different in your case)

Click OK and let tcpTrace run on the host computer.

On the virtual machine navigate the browser to the IP address of the host computer, for instance in my case: http://192.168.0.4/Default.aspx

and it will work!

PS. To get an IP address on the host machine, run ipconfig there (in a command prompt window). Your IP will be presented in the "IPv4 Address" line for network you're connected on.

PS2. Also my Windows 7 (host) doesn't come with any third-party anti-virus or firewall. It has a built-in Windows firewall and MS Security Essentials as an AVP. So if your setup is different one needs to open the incoming port 80.

PS3. Speaking of the VMWare Workstation, the virtual machine's network adapter setting is set on "NAT: Used to share the host's IP address" as it came out-of-box when you install it.