Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i am unable to get some client computer name not all visiting my intranet site.any one can help me on this please.
thanks

What I have tried:

C#
public string GetComputerName(string clientIP)
{
    try
    {
        var hostEntry = Dns.GetHostEntry(clientIP);
        return hostEntry.HostName;
    }
    catch (Exception ex)
    {
        return string.Empty;
    }
}

//call GetComputerName function

string computerName=GetComputerName(HttpContext.Current.Request.UserHostAddress)
Posted
Updated 7-Dec-17 2:24am
v2
Comments
Merajuddin Ansari 6-Dec-17 3:05am    
error: The requested name is valid, but no data of the requested type was found

1 solution

It is not a problem of your application. Possible reasons are that there is no DNS server for the network to which the IP belongs, there is a DNS server but that has no record for that IP, or the IP belongs to a different local subnet than the local subnet of your system.

You can check it on the command line with the nslookup utility:
nslookup ip-address
If that fails too, you can't do anything in your application besides catching this error and returning for example the IP address instead (catching errors is always a good idea; especially with operations that may fail for various reasons like network).

If there is a local DNS server but it does not have a record for that IP, you might also ask the administrator of that server.
 
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