trevorhartman
asked on
getting the host name
Hello all,
I'm working on a asp.net application being used internally within our local network. I need to get the Host Name of the station that is querying the aspx page. I tried Request.UserHostName but that returns the IP address, identical to Request.UserHostAddress.
Any way to do this?
Thanks - Trevor
I'm working on a asp.net application being used internally within our local network. I need to get the Host Name of the station that is querying the aspx page. I tried Request.UserHostName but that returns the IP address, identical to Request.UserHostAddress.
Any way to do this?
Thanks - Trevor
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks all, i ended up using:
string kioskHostIP = Request.UserHostAddress;
// do a reverse lookup to figure the HostName using the IP address
IPHostEntry hostInfo = Dns.GetHostByAddress(kiosk HostIP);
string kioskHostName = hostInfo.HostName;
Response.Write(kioskHostNa me + "<br>");
-Trevor
string kioskHostIP = Request.UserHostAddress;
// do a reverse lookup to figure the HostName using the IP address
IPHostEntry hostInfo = Dns.GetHostByAddress(kiosk
string kioskHostName = hostInfo.HostName;
Response.Write(kioskHostNa
-Trevor
Heya,
did you try Request.UserHostName ?
did you try Request.UserHostName ?
or more apptly put...
Response.Write("The kiosk Host Name is " + Request.UserHostAddress);
Response.Write("The kiosk Host Name is " + Request.UserHostAddress);
grrrrrrr
Response.Write("The kiosk Host Name is " + Request.UserHostAddress);
SHOULD READ
Response.Write("The kiosk Host Name is " + Request.UserHostName);
for completeness
Response.Write("The kiosk Host Address is " + Request.UserHostAddress);
Response.Write("The kiosk Host Name is " + Request.UserHostAddress);
SHOULD READ
Response.Write("The kiosk Host Name is " + Request.UserHostName);
for completeness
Response.Write("The kiosk Host Address is " + Request.UserHostAddress);
ASKER
Yeah i tried that - from my first post:
" I tried Request.UserHostName but that returns the IP address, identical to Request.UserHostAddress. "
thx anyway
-Trevor
" I tried Request.UserHostName but that returns the IP address, identical to Request.UserHostAddress. "
thx anyway
-Trevor
ah hah!.... hehe soz my mistake...
but therein i have more info on your problem...
Request.UserHostName - returns a string that contains the 'DNS' hostname...
DNS i hear u say!?
The problem you are having then is that the DNS server must be available and be able to resolve the client ip to a DNS name - if it cannot resolve it it returns the IP address as if you used Request.UserHostAddress.
so it seems theres a DNS resolution problem on your network.
but therein i have more info on your problem...
Request.UserHostName - returns a string that contains the 'DNS' hostname...
DNS i hear u say!?
The problem you are having then is that the DNS server must be available and be able to resolve the client ip to a DNS name - if it cannot resolve it it returns the IP address as if you used Request.UserHostAddress.
so it seems theres a DNS resolution problem on your network.
ASKER
could be, but this:
string kioskHostIP = Request.UserHostAddress;
// do a reverse lookup to figure the HostName using the IP address
IPHostEntry hostInfo = Dns.GetHostByAddress(kiosk HostIP);
string kioskHostName = hostInfo.HostName;
Response.Write(kioskHostNa me + "<br>");
works for me so i'm happy :)
string kioskHostIP = Request.UserHostAddress;
// do a reverse lookup to figure the HostName using the IP address
IPHostEntry hostInfo = Dns.GetHostByAddress(kiosk
string kioskHostName = hostInfo.HostName;
Response.Write(kioskHostNa
works for me so i'm happy :)
sweet :) -- its a lesson i am yet to learn -- if it works it works :p
anyhow trevorhartman,
you can use GetHostName with no parameters, this will return the host name of the local machine.
string strLocalHostName = Dns.GetHostName ();
look at the link in my post above for a fuller explanation and example c# code.