How to Get Client IP Address

P

Prabhat

Hi All,

I am trying to get the IP address of the Client machine and using the code:

Response.Write(Request.ServerVariables("REMOTE_ADDR"))

But I only get 127.0.0.1

It should be giving the IP address of the system or the gateway. How can I
get that. Please help.

Thanks
Prabhat
 
T

Turkbear

Hi All,

I am trying to get the IP address of the Client machine and using the code:

Response.Write(Request.ServerVariables("REMOTE_ADDR"))

But I only get 127.0.0.1

It should be giving the IP address of the system or the gateway. How can I
get that. Please help.

Thanks
Prabhat


Well that should work ( it does when I created this page called WhereFrom.asp:

<%
Response.Write(Request.ServerVariables("REMOTE_ADDR"))
%>

I placed it in a devfiles directory on our web server ( IIS 5) and, from my Client PC (using IE), went to
http://mywebserver/devfiles/WhereFrom.asp

and got my Client PC's IP address..


So I am at a loss to se why, if you followed similar steps, it should fail..
 
M

McKirahan

Prabhat said:
Hi All,

I am trying to get the IP address of the Client machine and using the code:

Response.Write(Request.ServerVariables("REMOTE_ADDR"))

But I only get 127.0.0.1

It should be giving the IP address of the system or the gateway. How can I
get that. Please help.

Thanks
Prabhat


http://www.aspfaq.com/5003
 
P

Prabhat

Well that should work ( it does when I created this page called
WhereFrom.asp:

<%
Response.Write(Request.ServerVariables("REMOTE_ADDR"))
%>

I placed it in a devfiles directory on our web server ( IIS 5) and, from
my Client PC (using IE), went to
http://mywebserver/devfiles/WhereFrom.asp

and got my Client PC's IP address..


So I am at a loss to se why, if you followed similar steps, it should
fail..

I have invoked the page like: http://localhost/website/page.asp that gives
me 127.0.0.1. Please suggest.

Thanks
Prabhat
 
P

Prabhat

That is the proper IP address for localhost.

If you want a different one then put your page on another Web server.

Or, if outsiders can visit your Web page then their IP address will show
up.

Us "winipcfg" to identify your IP address and use that
(from another computer) to access your page.
Hi,

Thanks for the suggestion. I have used http://MyComputerName/webpage.asp and
able to get the IP address correctly but using Localhost gives 127.0.0.1.

Thanks
Prabhat
 
E

Egbert Nierop \(MVP for IIS\)

Prabhat said:
Hi,

Thanks for the suggestion. I have used http://MyComputerName/webpage.asp
and able to get the IP address correctly but using Localhost gives
127.0.0.1.

localhost ***always*** returns 127.0.0.1 this is one of the standards that
the TCP/IP protocol implies.

If you start your command prompt (cmd.exe)
you try this for instance
ping localhost

you'll get the IP address as well.
 

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,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top