private void IPAddress() { IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIP = ip.ToString(); TxtExt.Text = localIP; } } }
Using thic code i am getting 87.101.226.125 which is unknown <script type="text/javascript"> window.onload = function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://www.telize.com/jsonip?callback=DisplayIP"; document.getElementsByTagName("head")[0].appendChild(script); }; function DisplayIP(response) { document.getElementById("ipaddress").innerHTML = "Your IP Address is " + response.ip; } </script>
public string GetIP4Address() { string IP4Address = String.Empty; foreach (IPAddress IPA in Dns.GetHostAddresses(this.Request.ServerVariables["REMOTE_ADDR"].ToString())) { if (IPA.AddressFamily.ToString() == "InterNetwork") { IP4Address = IPA.ToString(); break; } } if (IP4Address != String.Empty) { return IP4Address; } foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName())) { if (IPA.AddressFamily.ToString() == "InterNetwork") { IP4Address = IPA.ToString(); break; } } return IP4Address; }
string address = request.UserHostAddress;
<script type="text/javascript" src="Scripts/jquery-1.6.2.js"></script> <script type="text/javascript"> $.getJSON("http://jsonip.appspot.com?callback=?", function (data) { alert("Your ip: " + data.ip); }); </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)