I'm trying to get the IP address of a specific url using:
var ip = Dns.GetHostAddresses("http://oldschool.runescape.com/game?world=321")[0];
The problem is that this function only seems to work with the normal host adress (as the function tells, ex: www.runescape.com) which creates an exception when using this specific more deeper URL. Is there any function to get the IP of a more specific URL?
Thanks in advance.
The full url like that will have the same hostname. As easy way to get the hostname is this:
var url = "http://oldschool.runescape.com/game?world=321";
Uri myUri = new Uri(url);
var ip = Dns.GetHostAddresses(myUri.Host)[0];
Simply extract the host out of the url and that should prevent your error giving you the correct Ip address of the host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With