|
So here's my precarious situation: I'm writing some sample web applications for the iPhone. Every once in a while, I poke around using Ruby on Rails, but by and large my web development lately has consisted entirely of the ASP.NET MVC framework CTP. I also don't own a PC anymore - I own a Macbook Pro and an iMac. So, what's an ASP.NET developer to do?
VMware Fusion of course. The problem is that I've been pulling out my few remaining hairs trying to figure out how I can point my iPhone at my Windows Vista IIS residing inside a VMware Fusion Virtual Machine. For the longest time, I couldn't ping the VM from my host Leopard environment, and I couldn't ping the Leopard machine from the VM, so I thought I was dealing with a VMware problem. Turns out it was a little bit of both, and you need to configure both things properly.
Configuring VMware Fusion for IIS-related activities
First set the networking mode on the VM to "Bridged". Since both the VM and the host machine are connected to the same IP-supplier (if you're using DHCP like an in-home router), they will both have the same gateway (which is ridiculously important...if they don't have the same gateway you need a RIP-enabled router to forward packets...blick on that).
When this is working, you'll probably end up with a router/gateway IP address of 192.168.1.1 (though some routers prefer to use the 10.* local network, but it's far less common). In my case, my Windows Vista virtual machine had an IP address of 192.168.1.11 and my host Leopard OS had an IP address of 192.168.1.8, and the iPhone has an IP of 192.168.1.6.
Configuring Windows Vista inside a VMware Fusion VM for IIS-related activities
Here's where the fun starts. You will have to do the following in order, because if you don't Windows Firewall will turn itself back on and you'll have to add another extra step of shutting the Firewall off again.
1. Turn on some or all of the sharing features like public folder sharing, printer sharing, media sharing, etc. You need a couple of these on to make the Windows Vista machine pingable. Without these on, it will not respond to pings.
2. Turn off Windows Firewall. You might've turned it off before, but check again. Just to be sure, uncheck the checkbox next to the "Local Area Network" connection that indicates the firewall is protecting that connection.
3. You should now be able to ping the host Mac from the VM
4. You should be able to ping the VM from the host Mac
Finally, as a test, hit the IP of your Vista machine from Safari inside Leopard and you should end up with the IIS7 welcome screen below:

It really should not be this difficult to get working, but between the complexity of bridged VMware networking and the zealousness with which Windows Vista protects its innards, it can be daunting.
With all of this infrastructure in place you can now use the file-based ASP.NET MVC project and test it locally within your VM using the Cassini internal VS2008 web server. When you're ready to test the iPhone GUI, layout, and responsiveness on a real phone rather than using Safari for Windows as your test environment, just publish your project to IIS and you can hit it from your iPhone.
The frustration involved in getting this to work properly was almost enough to get me to switch to a different web development environment... almost. :) Hopefully this blog post makes your setup easy if you have a similar environment.
Awesome! Thanks for sharing this.
Stay tuned to MIX '08. Scott Guthrie has said that they're going to be
dropping another CTP of the MVC stuff that should fill in some of the gaps
they've identified in the preliminary bits. I'm hoping for some improved
Ajax support. Controls work fine for me so I don't need sub-views yet, but
then I haven't tried out a lot of different scenarios. I've got a lot of
validation working, but it's fairly manual at the moment. The "Flash"
(TempData) dictionary works well for delivering validation failure
messages.
I'm not *quite* like you. I use a Mac.. but I don't develop .NET stuff..
;)
Kevin, I can't recall seeing any posts about this in your blog.. so I'll
ask.. I know you're using VMWare.. but did you ever try Parallels? What
was your experience there?
I have tried parallels a few times during beta and then I believe I spent a
little bit of time with the retail copy. I don't have anything against
Paralells per se, but I have so many other VMware workstation images lying
around from work and on other machines that it made perfect sense for me to
use Fusion, since it can work with existing VMware workstation files
(provided they are using 2GB files.. I had trouble with a single 18GB disk
image file..)
I hear ya. That's actually an excellent point about Fusion. I pulled a
VMWare machine that was built with VMWare for Windows... shuffled things
into a folder .vmwarevm extension and I was off and running. That's very
slick. For me I've just found that for Windows, Parallels and coherence
just seems to work *better*... Unity on VMWare just still seems a little
rough around the edges (for lack of a less cliche term).