Kevin Kallberg

The life and times of a software developer

NAVIGATION - SEARCH

Windows Phone 8 Emulator and Local Web API

The Windows Phone 8 Emulator differs from previous Windows Phone emulators in that it is a full fledged virtual machine running on Hyper-V.  This creates difficulty when attempting to test local web services utilizing ASP.NET Web API.  The Windows Phone client cannot simply reference localhost like it did in the past.  Instead, you must make the service available to the emulator as an independent device.  There are a few hoops to jump through to make this happen and here's how I achieved success.

Reorder network adapters on the Emulator

  1. Remove all network adapters from the Emulator in Hyper-V Manager
  2. Add network adapters back on the Emulator beginning with the Wireless adapter, then Wired Ethernet, then Internal Windows Phone
  3. At this point I was able to access internet resources like google.com and kevinkallberg.com from within the emulator.

Tell IIS Express to allow traffic to connect on an IP address in addition to localhost

  1. Stop the Web API site.
  2. Right-click and Exit IIS Express in the system tray.
  3. Open the folder %USERPROFILE%\Documents\IISExpress\config\
  4. Edit the file called applicationhost.config
  5. Locate the Site XML node under <configuration><system.applicationHost><sites> that matches your site.
  6. Copy the binding node similar to this one:  <binding protocol="http" bindingInformation="*:<port>:localhost" />
  7. Paste the binding node directly underneath the existing one and replace localhost with your current IP address.
  8. Add additional bindings if you wish for each of the host machine's network adapters.
  9. Restart the Web API site and ensure that you can browse to it on the host machine via localhost:<port> and <ipaddress>:<port>

Add an exception in the Windows firewall

  1. Create an inbound rule allowing traffic on the port that IIS Express is hosting the Web API service.  
  2. Allow this exception on Private and Domain network profiles, but not Public.

At this point, you should now be able to access the Web API site from IE Mobile on the Windows Phone Emulator by navigating to http://<ipaddress>:<port>.

Remember you can use the Pause/Break key to toggle keyboard functionality inside the Emulator.

Good luck!

SVN Global Ignore Pattern

This is the global ignore pattern that I use with Subversion.  It covers Visual Studio, ReSharper, NCrunch and more.

.git target* *\bin *\bin\* *\obj *\obj\* *.suo *.user *.bak *\_NCrunch_*.* *.ncrunchproject *.ncrunchsolution *.crunchsolution* *.userprefs *.ReSharper** **\_ReSharper.** **\StyleCop.Cache **\*.dotCover *.releaseBackup release.properties *.versionsBackup *.diff *.vssscc *.vspscc *.scc *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__ *.rej *~ #*# .#* .*.swp .DS_Store