Pregunta

I've already tried these methods:

  • System.Net.Dns.GetHostName
  • Environment.MachineName
  • My.Computer.Name
  • Environ$("computername")

Each returns APPDEV, which I assume is the name of the server hosting my web page.
I've even asked friends to try my page with these methods and they see the same thing.
How can I get it to return the PC name entered at initial setup, like Joseph-PC?

¿Fue útil?

Solución

Since the browser won't tell the computer name to the server, a web page is (thankfully) not able to know your computer's name.

Otros consejos

You can try HttpContext.Current.Request.UserHostName. Similarly, UserHostAddress retrieves the IP of the client. But this information might not be valid in most circumstances due to (legitimate) privacy or network (NAT, Proxies, ...) reasons. So I wouldn't rely to strong on the presence or validity of the data.

If you are provided an IP address in UserHostName, you can use System.Net.Dns.GetHostEntry to make a DNS reverse lookup to find the name. This also might not work under all circumstances as not every client is registered at a DNS server.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top