string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ipList))
{
return ipList.Split(',')[0];
}
return Request.ServerVariables["REMOTE_ADDR"];
i am using above code. but its returns localhost address like 127.0.0.1. how can i use this code
How to remote ip address of my machine?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sunny SharmaRank #223 · 11.1K reputationPosted Oct 5, 2013, 2:19 AM EDT
I'm not getting the point here. If you try to get the IP of your local machine, it will give you 127.0.0.1 and that is Correct. So, what do you expect it to return?
Veena SardaRank #79 · 24.5K reputationPosted Oct 6, 2013, 10:09 AM EDT