Accessing a .NET Virtual Machine Application from a Host Machine

I’ve recently been working on a .NET web application. We are mainly a Mac-based development shop at Atomic, so I’m working on this application in a virtual machine. My weapons of choice are VMWare Fusion and Visual Studio 2012 (not much of a choice), but that is neither here nor there.

Our application uses the Helvetica Neue font family. This font comes pre-packaged with Mac, but isn’t included in Windows. So, in order to effectively design and preview our application, I needed to make it available from my host machine. Here is how I did that.

  1. Run your application in IIS Express.
  2. Open your project’s property file and select the Web tab. Under the ‘Servers’ section, select Use Local IIS Web Server. Visual Studio may ask you to create a virtual directory for the application… go ahead.

  3. Set up a domain for your application.
  4. In order to access your application from the host machine you need to make changes to the IIS configuration file. This file is located on disk at My Documents\IISExpress\config\applicationhost.config. Find your project configuration within the <sites> tag. In the binding section, add a new binding for your application. It will look something like this:

    <binding protocol="http" bindingInformation"*:5500:local.mywebsite.com" />
    

  5. Add a Windows firewall rule for your application.
  6. Your application will not be visible outside of the virtual machine unless the port is open for communication. To open the port, open up ‘Windows Firewall with Advanced Security’. Right-click the Inbound Rule item in the left navigation and select New Rule.

    Create a Port rule for your project. In my example we needed to open port 5500. Go through the setup wizard, selecting the options that apply for you, and give your rule a meaningful name.

  7. Add a new entry in your hosts file.
  8. On your host machine, you will want to add a new entry for your virtual machine. Open your /etc/hosts file and add an entry that looks something like: 192.168.1.100 local.mywebsite.com

  9. Use a static IP for your virtual machine.
  10. Every time you reboot your VM, it will most likely get a new IP address. This will invalidate your host’s file, and your project will no longer load from your host machine. In order to fix this, I suggest giving your virtual machine a static IP. You can follow this guide.

And that’s it! You should now be able to open your browser of choice on your host machine and navigate to local.mywebsite.com:5500 and see your VM based web application. Happy debugging!