getting host name

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

is there a way to get the host name of someone? like mine is
68-23-123-123-pitt-pa.adelphia.net?

Request.UserHostName doesn't seem to return the host name like it states in
the documentation, only gives me back an IP address.. which is what I
assumed Request.UserHostAddress would do... they both return the same values
all the time
 
I just tried that and it seems to only be returning the host name of the
server, shouldn't this be the host name of the client? which is what I want
not the server the application it is running on... REMOTE_HOST returns the
client IP, but I want the client host name.. thanks!
 
the REMOTE_HOST returning the IP instead of the actual hostname is a
server configuration. Most servers disable reverse lookup because it
does slow things down unnecessarily.

You will usually have to do the reverse lookup yourself manually and
you can use the following code as a basis

System.Net.IPHostEntry TmpEntry =
System.Net.Dns.GetHostByAddress(Request.ServerVariables["REMOTE_ADDR"]);
Response.Write(TmpEntry.HostName + "<br />");
 
re:
shouldn't this be the host name of the client?

No. It's the host name of the http server.

re:
I want the client host name

You can't have that, since the client is not hosting anything.

You could, if you need that info, do a reverse DNS query.
*That* would give you the client's name, if any exists.




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
Hmm...

I thought that would get you the machine's name,
but not the DNS name.



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
Back
Top