Hai all,
How to get the Public IP (183.82.1.30) address using asp.net, i get the ip address like 192.168.1.1 but i need network ip address please help how to find via code in asp.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Keyur PatelPosted Jan 14, 2014, 4:35 AM
Please try following solution
1) You can open following link in your form or use the web client libraries to fetch http://whatismyip.org/.
2) You can use following code to get public IP
2) http://www.codeproject.com/Questions/399318/How-to-Get-User-IP-address-using-csharp
Keyur PatelPosted Jan 14, 2014, 4:35 AM
Please try following solution
1) You can open following link in your form or use the web client libraries to fetch http://whatismyip.org/.
2) You can use following code to get public IP
public void GetIP()
{
string IPAddr = string.Empty;
if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
{
IPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
{
IPAddr = HttpContext.Current.Request.UserHostAddress;
}
uip.Text = "Your IP is: " + IPAddr;
}
3) http://www.codeproject.com/Questions/399318/How-to-Get-User-IP-address-using-csharp