I have application want to get user machine name, here I can retrieve and it works fine in localhost.
string clientPCName;
string[] computer_name = System.Net.Dns.GetHostEntry(
Request.ServerVariables["remote_host"]).HostName.Split(new Char[] { '.' });
clientPCName = computer_name[0].ToString();
In local it returns exactly my computer name.
But on server I get result like this: 0x57364794
Any solution?
In order to retrieve the client's computer name, you will have to query the DNS server with the client's IP. The IP can be easily retrieved by using the ASP.NET Request object with its UserHostAddress property.
Try this it works for me
string clientMachineName;
clientMachineName = (Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName);
Response.Write(clientMachineName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With