Re: [2008] ASP.NET (VB) - How to retreive a client's IP
Doken13, here's sample code to retrieve either a real client IP
or a proxy's IP...and determine which is which :
// HTTP_VIA is not null if there's a proxy between your server and the client
if(Context.Requ est.ServerVaria bles["HTTP_VIA"]!=null)
{
// So, this code returns the client's real IP
ip=Context.Requ est.ServerVaria bles["HTTP_X_FORWARD ED_FOR"].ToString();
}
else
{
// not using proxy or can't get the Client IP
//doesn't get the Client IP, but returns proxy IP
ip=Context.Requ est.ServerVaria bles["REMOTE_ADD R"].ToString();
}
As George says, you can not always get the Client IP through a proxy because
either a proxy will not send the client IP to you or a client can also be prevented
from sending its IP by the use of "header_acc ess deny".
--
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaƱol : http://asp.net.do/foros/
=============== =============== ========
"George Ter-Saakov" <gt-nsp@cardone.com wrote in message news:uwJinTotIH A.1436@TK2MSFTN GP05.phx.gbl...
Some proxies report in a request's header the actual client IP address.
There are 2 or 3 standard headers. x-forwarded-for is one of them
>
But some proxies do not do it. Those proxies called anonymous proxies by the way.
>
George.
>
"Doken13" <astef31@hotmai l.comwrote in message news:udRIVDntIH A.3968@TK2MSFTN GP04.phx.gbl...
>>I got an intranet web site and there is a proxy on the network.
>I want to retreive a client's IP, how could I get it ?
>>
Comment