Running localhost REST Web API on MacBook Pro with VMWare + Xamarin

If you developing REST Web API services for mobile x-platform apps sometimes you need to locally debug and test using emulators (iPhone or Android) running on Mac before publishing REST to the server…
Or if you’re need to test your app on a plane ride without connection to the published service… etc… you’re came to the right place.

Developer Setup

1) MacBook Pro (OS X Yosemite v 10.10.4)
2) Windows 8.1 running in VMWare Fusion (v 7.1.2)
3) Visual Studio 2013 running in the Windows 8.1
4) Xamarin Studio (v 5.9.4)

Follow these 7 steps and you’ll be able to do this

1) Change Network Adapter Setting on the VMWare’s instance of Windows to “Bridged Networking” (Wi-Fi will allow actual devices iPhone/iPad or Android to run websites and REST WebAPI on your Windows)

2) Set up IIS in the VMWare’s Windows environment (Windows 8.1 in this example)

a) Open “Control Panel”

Screen Shot 2015-07-23 at 1.46.01 PM

b) Select “Programs and Features” then select “Turn Windows features on or off”

Screen Shot 2015-07-23 at 1.46.26 PM

c) Select “Internet Infromation Services” and make sure WWW Service has
“.NET 4.5” selected as well as “Security/Window Authentication” is selectedScreen Shot 2015-07-23 at 10.57.32 AM

 

3) Setup “Windows Firewall” to allow incoming HTTP Requests
(Control Panel/Windows Firewall/Allow an app or feature through Windows Firewall)

4) Run “ipconfig” in Command Prompt to find out the VM’s IP address (in my case 10.0.1.13)

Screen Shot 2015-07-23 at 8.05.56 PM

5) At this point you should run the IIS from Safari browser (or any other device in your network i.e. iPhone/iPad etc), just type your IP address (in my case 10.0.1.13)

Screen Shot 2015-07-23 at 8.16.16 PM

 

6) Setup Visual Studio with your WebAPI project to run in local IIS (here is a link to a sample code for WebApplication2)

a) In Visual Studio select your project properties/Web and select “Apply server settings to all users (store in project file) and select “Local IIS” from the dropdown

Screen Shot 2015-07-23 at 1.43.56 PM

b) compile and run (in Windows you will access it in http://localhost/WebApplication2 from Mac http://10.0.1.13/WebApplication2)

Screen Shot 2015-07-23 at 1.52.28 PM

 

7) VOILA..! now you can access your WebAPI Application running locally on your Mac OS, inside VMWare Windows. Access it from other emulators on your Mac, Safari or other browsers and mobile devices on your local wi-fi network

Here is a link to a sample TestWebAPI Xamarin Forms application to test any REST WebAPI rest point

Leave a Reply

Your email address will not be published. Required fields are marked *