I am trying to get the computer name for the current user. I am able to get the IP address using System.Net.Dns.GetHostEntry("ComputerName").Address.ToString()
but when I replace the *ComputerName*with the IPAddress I receive the following error.
No such host is known
I enabled reverse DNS in IIS7 by running command: Cscript.exe adsutil.vbs set w3svc/EnableReverseDNS TRUE in the C:\inetpub\AdminScripts directory on my server.
Any ideas on what I'm doing wrong?
The overall purpose is that this will be a help desk application and it will be useful for a user to be able to easily provide their computer name for assistance.
Locally everything works but it does not work once published to the server.
You can try this :
string machineName = GetMachineNameFromIPAddress(yourIPAdress);
private static string GetMachineNameFromIPAddress(string ipAdress)
{
string machineName = string.Empty;
try
{
IPHostEntry hostEntry = Dns.GetHostEntry(ipAdress);
machineName = hostEntry.HostName;
}
catch (Exception ex)
{
// Machine not found...
}
return machineName;
}