Hiiiiiiiii
i need IP address of the current user in Asp.net,i used below code to get IP Address ,but i am getting IP Address of the User LAN,please suggest me
var ipAddress = HttpContext.Current.Request.ServerVariables["X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ipAddress))
{
ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}

Joginder BangerRank #360 · 7K reputationPosted Nov 11, 2014, 6:48 PM EST
try the following code
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
Console.WriteLine(hostName);
// Get the IP
string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
Console.WriteLine("My IP Address is :"+myIP);
Console.ReadKey();
nagendra prasad30 reputationPosted Nov 11, 2014, 7:10 PM EST
nagendra prasad30 reputationPosted Nov 11, 2014, 7:36 PM EST
Joginder BangerRank #360 · 7K reputationPosted Nov 11, 2014, 7:44 PM EST
for more information about the method hit this link
http://stackoverflow.com/questions/19285957/how-to-get-public-ip-address-of-a-user-in-c-sharp
protected void GetUser_IP() { string VisitorsIPAddr = string.Empty; if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) { VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else if (HttpContext.Current.Request.UserHostAddress.Length != 0) { VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress; } uip.Text = "Your IP is: " + VisitorsIPAddr; }
nagendra prasad30 reputationPosted Nov 11, 2014, 7:51 PM EST