Stacking Overflows Stacking Overflows - 28 days ago 6
C# Question

How to get the computer name using the IP Address

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?

Update



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.

Answer Source

Thanks to all that answered this post.

Actually, the code was not the problem. There was nothing wrong with the code that I was trying or the suggestions made. I found out that the server DNS entry was not set up correctly.

Maybe this will help someone else.