How to get the IP of Server and client?

A

ad

Hi,
I am use VS2005 to develop Web application.
How can I get the server's and client's IP with program?
 
G

Guest

Try to use this:
to get HOST IP use Request.ServerVariables["LOCAL_ADDR"]
to get client IP use Request.UserHostAddress

--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
 
S

Sarat Pediredla

Mark,

Under that argument, nothing can be relied upon that is sent from the
client :) . As far as stats go (and as I work with them) getting the
request IP is the closest to obtaining the user's IP. Unless there is a
better way?

Sarat
 
M

Mark Rae

Under that argument, nothing can be relied upon that is sent from the
client :) .

That's pretty much the case - quite a few browsers have an "impersonate"
option where they can "appear" to be something else entirely...
As far as stats go (and as I work with them) getting the request IP is the
closest to obtaining the user's IP.

So long as you trust your users not to spoof it...
Unless there is a better way?

There isn't...
 
M

mark

Sarat Pediredla wrote:

Sarat,
Under that argument, nothing can be relied upon that is sent from the
client :) . As far as stats go (and as I work with them) getting the
request IP is the closest to obtaining the user's IP. Unless there is a
better way?

Have a look at the properties of my earlier reply - you can see from my
IP address that I'm in the UK, etc...

Have a look at the properties of this reply - where do you think I am
now?

You simply cannot rely on the IP address reported to your server...

Mark
 

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

Top