How can I get the client's computer name in a web application?
Regards
// Already tried this option
string ip = system. Web. Hpptx Present. request. UserHostAddress; String compName = DetermineCompName (IP); System.Net.IPHostEntry teste = System.Net.Dns.GetHostEntry (IP); Ssresult = IP + "-" + teste.HostName; // TODO: Write Action for Action Write Private Static String CompName (String IP) {IPAddress myIP = IPAddress.Parse (IP); IPhost Entry GetIPHost = DNS Gatehostentor (IIP); String [] compName = GetIPHost.HostName.ToString (). Split ('.'); Return COMPName [0]; }
All this gives me only the IP: /
You can not do such a thing that guarantees work.
The closest approach you will be able to get is to go down the path to reverse DNS lookup using the System.Net.Dns.GetHostEntry
that you have already tried
The problem is that there is no way to know the remote web client's hostname through your IP address only (unless it is on the same subnet, in which case you To recover it).
You have to come back to your DNS infrastructure which is able to map the IP back to a hostname [this is exactly what you type in a hostname], and not just bother at many places. Reverse IP record will be up.
Plus, if they often do, they will not match hostname. Reverse lookup for "1.2.3.4" is quite common to see, instead of the actual hostname, come back in the form of some line "Machine-1.1.3.4".
This problem goes forward if the client is behind any kind of network address translation so that many client computers have an IP from an external perspective. Maybe this is not the case for you because you say "Users in Network"
On the one hand, if you go to the server and type at the command prompt, then
nslookup < Some IP & gt;
(Where is an example of one of these client machines), do you get back a hostname?
If you do, then the System.Net.Dns.GetHostEntry
should be enabled as well, if it is not, then probably not for the reasons mentioned above.
Comments
Post a Comment