How to retrieve a visitor's IP address
Every visitor to your site or web application has an IP address. It is quite handy to be able to get that address. It can be used for security logging, or perhaps tracing. It can also be used to determine where they are in the world, or at least where their ISP is.
The difficulty is when they're behind a proxy of some sort, you only see the IP address of the proxy server. So, here are the code snippets in PHP, ASP and .Net that first check for an IP addresses that's forwarded from behind a proxy, and if there's none then just get the IP address.
Here it is in PHP
And here's how to get the IP address in ASP
ip_address = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ip_address = "" then
ip_address = Request.ServerVariables("REMOTE_ADDR")
end if
%>
And here's the IP retriever with proxy detection in .Net (C#)
{
string strIpAddress;
strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIpAddress == null)
{
strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
}
return strIpAddress;
}
And here's the same IP retriever with proxy detection in .Net, but in VB.Net
Dim strIpAddress As String
strIpAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If strIpAddress = "" Then
strIpAddress = Request.ServerVariables("REMOTE_ADDR")
End If
IpAddress = strIpAddress
End Function

on December 21st, 2006 at 2:10 am
You do not need to search for working free web proxies. All is here.
Find free web proxy for desired country!
All proxies are regulary checked if they still alive.
enjoy it!
on February 6th, 2007 at 4:17 am
I used the IP retriever using C#.But it is always returning the IP Address of my server instead of visitor's ip address.Is there any alternative
on February 10th, 2007 at 2:53 pm
Hi, I would like to find out, if there is a possibility to retrieve an IP knowing the yahoo messenger IP. I am asking this, because I sometimes get uninvited people, who use a pornografic ID, and their messages are as well their ID… I just wanna know if there is any way to get their IP so I may trace them… Doesn't matter if they are using a Net Caffee or somthing similar. Thank you…
on February 11th, 2007 at 10:55 am
Sorry, I've never had to do that, so I have no idea. You may want to look on Daniweb or somewhere similar
on May 31st, 2007 at 7:16 pm
how do u get there in the first place and it would be nice if your site had a whole list of proxy sites since im always looking for new ones since my skool always find thems after 1 day
on June 6th, 2007 at 7:02 pm
good info
http://www.essaytown.com
on July 3rd, 2007 at 5:58 am
I want to get IP address of visitor to start an online voting which able to know the visitor cast vote single time only.
Thanks
on July 3rd, 2007 at 7:39 am
For that I would just look for an open source polling class. That functionality is always built in
on June 27th, 2008 at 11:15 am
thanks for the info.. it helped
garaki