Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello all,

I have used VS2010 on windows 7 64bit machine. I can get host name on 32bit machine and working fine. But I got error as "No such Host is known" when using 64bit machine.
I was tryed all these 3 ServerVariables but still i got error.
C#
Request.ServerVariables["REMOTE_ADDR"]
Request.ServerVariables["REMOTE_HOST"]
Request.ServerVariables["REMOTE_USER"]

My code is:
C#
string hName = "";
System.Net.IPHostEntry host = new System.Net.IPHostEntry();
host = System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);

if (host.HostName.Contains("."))
{
string[] sSplit = host.HostName.Split('.');
hName = sSplit[0].ToString();
}
else
{
hName = host.HostName.ToString();
}
Posted
Updated 3-Apr-13 21:21pm
v3
Comments
Sugu.s 4-Apr-13 7:30am    
Yes, i have seen it. but not working for 64 bit machine.

It has nothing to do with the bitness of the machine. It has everything to do with whether the remote machine is registered in a DNS accessible by the server or not. Apparently, your 64-bit machine is not.
 
Share this answer
 
Comments
Maciej Los 4-Apr-13 7:49am    
Logically ;)
+5!
C#
Shrotest Way to get Client PCName

string clientPCName;
string[] computer_name = System.Net.Dns.GetHostEntry(
Request.ServerVariables["remote_host"]).HostName.Split(new Char[] { '.' });
clientPCName = computer_name[0].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900