Get External IP

M

Marc Rivait

I have been struggling this one. As part of a application we want to
control IP addresses which come to our site.

On the web page we get the IP of the client computer using
Request.UserHostAddress(). However, if a user is coming to us from behind a
NAT, all we get is the internally assigned IP. We need to see the external
IP. I have not been able to find a method for getting this.

Thanks,
Marc.
 
C

Curt_C [MVP]

You won't, not with a server technology at least. If they are coming through
some sort of VPN/etc and getting a NAT then that's what you'll get really.
Same thing if people are behind a proxy, you may get ONE IP for an entire
company.
 
R

Raterus

Actually I think you have it backwards, NAT takes the internal ip and rewrites the packet with the external ip, if your visitors are hitting your site with an internal IP, they never had an external ip to begin with, and there would be no way of getting it unless you reroute traffic.

It's probably much easier and more secure to control IP access at IIS rather than in your asp.net application., you should be able to make it so only certain IP's can access your site.
 

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,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top