Derek
Derek

Reputation: 8630

Get Xamarin Android Device calling ASP.NET Web APi running Localhost

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?

Upvotes: 3

Views: 4187

Answers (1)

Ken Kosmowski
Ken Kosmowski

Reputation: 384

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.

Upvotes: 1

Related Questions