简体   繁体   中英

Get localhost web page by IP Address

I have a android project which feeds XML data from URL from web. I want to test this but I don't own a web address.

Therefore I created a XML Page on ASP.NET project and put the URL on android project. But the localhost URL didn't work.

How can I create a project in Visual Studio such that I can give the IP Address in the Android Project. I went through this tutorial about TCP Client but cannot resolve a solution for my problem. (I don't have an IIS Server so please don't give it as a solution)

If you are using real device via Wi-Fi network, your real host IP address should work. If you're using emulator, then your host address is 10.0.2.2 (see documentation here ).

Localhost usually resolves to 127.0.0.1 and is reserved for the local machine only. I assume that your machine has a networks card of some description and as such will have an IP address. This may be assigned automatically by your router (ADSL/Cable/Etc) but it will have one. If you are not sure what it is (and assuming, since you are talking about VS you are developing with a PC) then open a command prompt and type

ipconfig /all

You will then get back a list of network devices and one of them will be your NIC. You should also see the IP address associated with it.

The final thing to do is ensure that your windows firewall is not blocking access to the port(s) used by your mobile app. Should all be fine after that. If you have another PC then try browsing to the XML hosted page using that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM