Send a POST request from an Android phone to Visual Studio in localhost
I need to send a POST request to my Visual Studio localhost web server using my Android application. I need to do this for debug purposes.
I don't know how to allow my phone to reach the localhost. I tried to use the co开发者_运维知识库mputer IP address but it doesn't work. Any help?
You probably need to modify your firewall on your computer to allow incoming connections on the necessary port.
In the end, I used a phone emulator to access locally the localhost server and it worked really well. From the phone, I called the address 10.0.2.2 and it connected to the localhost server.
Your question is mis-stated.
Assuming what you want to do is access a server running on your PC:
You will have the most luck putting the phone and the PC on the same local area (wifi) network.
You may be able to achieve a local network over USB with some tethering solutions.
If the PC and the phone are not on a the same local network, the PC will need to have a globally routable IP address, in order for the phone on it's mobile network to be able to reach it. Many personal ISP solutions do not easily allow for this, due to dynamic IPs, personal routers implementing NAT, or with the IPv4 space being exhausted carrier grade NAT meaning subscribers do not have a unique IPv4 address even temporarily.
精彩评论