Capturing IP Address

  • Thread starter Thread starter tma
  • Start date Start date
T

tma

How does one capture the IP address of an incoming connection to an ASPX
page?
 
Hi,

You can use the HttpReferer to find the IP address .

Thanks
Raghavendra
 
How does one capture the IP address of an incoming connection to an ASPX
page?

Best to do a newsgroup search before posting - this question was asked and
answered only yesterday...
 
Raghavendra said:
Hi,

You can use the HttpReferer to find the IP address .

Generally speaking, you cannot. First, referrer identifies the resource (web
page) from which the request was made (hyperlink clicked on), which is
normally not the user's host. If you don't click a hyperlink or use any
other navigation control, there'll be no referrer anyway. Also, both clients
and proxies are free to change or omit this header, so don't blindly assume
it's there.

You can obtain the client IP address through the HttpRequest.UserHostAddress
property, but that's only the last client in the request chain (could be a
proxy for example).

You'll have to use a mixture of UserHostAddress and extension headers like
X-Forwarded-For to obtain more relibale data, and even that won't be
perfect.

Cheers,
 
Try Request.ServerVariables("REMOTE_ADDR")

How does one capture the IP address of an incoming connection to an ASPX
page?
 

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

Back
Top