How to get the IP address of the Client (visitor of the website)
I tryed with theese codes:

Request.UserHostAddress;  
and
Request.ServerVariables["REMOTE_ADDR"]

But both gave me back the serrver IP :(

Recommended Answers

All 2 Replies

You are correct in using Request.UserHostAddress . If you use a browser on the server and navigate to the page then of course you would get the servers ip -- since it is both the client and server. If you use a remote client then you will see a different IP address. If you have some fancy SNAT'ing going on in the network then you may be getting the incorrect IP address but there isn't much you can do about it.

I use Request.UserHostName to get clients' IP Address

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.