3
votes

I've managed to use the following guide for enabling my VS2015 Android Emulator access to a ASP.NET WEP API running on my local-host which is great :-

http://briannoyesblog.azurewebsites.net/2016/03/06/calling-localhost-web-apis-from-visual-studio-android-emulator/

But i would also like to configure my Xamarin application for enabling my external android device the same access to the web api.

At present, when running from device, the webclient makes the request but it never completes, which leaves the application hanging.

Does anyone know how I can achieve this?

1
what did you set in your applicationhost.config ?Daniel
The Ip address of the Network2 Adapter for the emulator as in the tutorial. It works fine on the emulator but not on the physical device.Derek

1 Answers

1
votes

Check your applicationhost.config, find the bindings for your WebApi. There should be something like this:

<binding protocol="http" bindingInformation="*:<your-port>:localhost" />

Add a binding for external requests:

<binding protocol="http" bindingInformation="*:<your-port>:*" />

Then your device can make requests to

<your-network-IP-of-your-machine>:<your-port>

Your device and your machine hosting the WebApi needs to be in the same network, e.g. your local WiFi.