c# - The ipaddress string is returning ::1. How can i get the full ipadrress of the user testing from localhost -
I want to retrieve the user's IP address, which is logged using C #.
I have written the following code
var ipaddress = System.Web.HttpContext.Current.Request.UserHostAddress; but ipaddress contains :: 1 . How do I get the full address? I'm just testing the code in the local host. IIS7 is installed.
:: 1 according to the specs is actually pointing to the loopback A valid address if you want a computer to get a public IP address, you must use a domain name (DNS returned to your local computer with DNS) or the location of localhost in the URL Use your public IP at Edit
Your code is good (some to change there O Is) Although you must translate back into trying to get your public IP wrapper (No 1 or 127.0.0.1) Call http other interface you must (meaning that IP to the DNS query). You will not be able to do that offline.
I hope it helps, sorry that I can not be clear. This is more programming of a networking problem.
Comments
Post a Comment