needs to access the same API

F Dhcdgb 60 Reputation points
2023-12-05T11:43:58.6566667+00:00

I have a API.

I am developing a MAUI Android app that needs to access the same API but I can't make it work.

HttpClient client = new();

Uri baseurl = new Uri("http://localhost:8086/api/Login/");

Any ideas how to solve this or any way around or some Emulator config?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,176 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 71,836 Reputation points Microsoft Vendor
    2023-12-06T06:10:52.88+00:00

    Hello,

    Emulated device can't detect your development machine or other emulator instances on the network. It detects only that it is connected through ethernet to a router or firewall. The virtual router for each instance manages the 10.0.2/24 network address space. All addresses managed by the router are in the form of 10.0.2.xx, where xx is a number. Addresses within this space are pre-allocated by the emulator or router as follows:

    From Google emulator network addresses document, you can set the 10.0.2.xx to replace localhost.

    Or please use android devices and connect to the same network environment.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful