[2008] ASP.NET (VB) - How to retreive a client's IP

D

Doken13

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 ?
 
G

George Ter-Saakov

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.
 
J

Juan T. Llibre

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.Request.ServerVariables["HTTP_VIA"]!=null)

{
// So, this code returns the client's real IP
ip=Context.Request.ServerVariables["HTTP_X_FORWARDED_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.Request.ServerVariables["REMOTE_ADDR"].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_access deny".





--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top