2
Answers

Getting the remote IP address of a visitor to my site

Ken Barrett

Ken Barrett

15y
3k
1
How can I get the IP address of a visitor to my site?

The documentation I can find on RemoteAddress is pretty confusing.

I found one item on the web showing :

string ip=Request.ServerVariables("REMOTE_ADDR");

But I get errors with that.  So I'm at a loss here.

TIA
Ken
Answers (2)
0
Roei Bar

Roei Bar

NA 7.8k 0 15y
use Page.Request.UserHostAddress;
Accepted
0
Ken Barrett

Ken Barrett

NA 173 0 15y
Ok, stupid me... this seems to work.

String hostName = System.Net.Dns.GetHostName();
lblIpAdr.Text = hostName ;