I often use the Android Emulator to do testing on a Xamarin Forms app, or Cordova, or something of the sort.
It’s a long round trip to point at test when you want to debug the backend behaviour, so let’s point it at local dev!
The Android Emulator maps
localhost, so can we just do that?
In Kestral, yes!
I changed my Xamarin Forms app to point at
http://10.0.2.2:5042 (my Kestral backend) and it Just Works.
Wonderful, but…what if we’re working with IIS?
Here’s the process I found after much Stack overflow (but essentially this one)
Request from emulator isn’t coming from localhost, it’s coming from 10.0.2.2 or some redirection, so need to allow it in IIS (since it’s first in the chain)
EDIT: May not need to copy, might be able to just set it to
EDIT: Sept 2022
This tends to fail to run on PC restart (
unable to parse hostname)
Changing back to
localhost and running, then stopping and making it
* again works…Weird, but fine.