-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
For MAUI run on Windows, it is easy to access localhost, it's simply localhost.
For MAUI run on Android emulator, simply replace localhost with 10.0.2.2
This is from this guide: https://docs.microsoft.com/en-us/xamarin/cross-platform/deploy-test/connect-to-local-web-services and it works fine.
For SQL Server Express used from emulator there is a nice tutorial here which works (the most important part is to open TCP/IP connections in the server config) (however the new Microsoft.Sql.Data client does not work on Android or works only for newer Android (depending on the version)):
https://www.youtube.com/watch?v=xNmIdFjXzl4
But for Android device which runs MAUI application attached via Visual Studio debugger? 10.0.2.2 doesn't work.
How to please connect to a service hosted on localhost?
Not only HTTP but also TDS or any other protocol.
There is no guide for Android device afaik. But testing must be done also on a real device!
Thank you.
Public API Changes
Add documentation on how to access localhost from Android device when running via Visual Studio (both Debug and Release).
Intended Use-Case
Simulating production environment with MAUI app,
Possible workaround
- to connect localhost to Android device, if these are on the same network, a temporary private IP can be exposed by localhost and ports with applications open. However this is not a robust solution and router can frequently change the private IP addresses assigned to devices (having a static private IP address in a network is not guaranteed)
VS bug #1745020