title: How I can obtain client hostname, local computer name and user name in c# and asp.net
body: <p>I have the IP address, but for some reason I can get the name resolve correctly to show local computer name. I try few things and all of them is showing the server hostname?</p>
  
  <pre><code>    ipadd = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
      IPAddress myIP = IPAddress.Parse(ipadd);
      IPHostEntry GetIPHost = Dns.GetHostEntry(myIP);
  
  
      //userhostname = System.Environment.MachineName;
      //userhostname = Dns.GetHostName(); //Resolve ServerHostName not computer
      //userhostname = HttpContext.Current.Request.UserHostName;
      //userhostname = HttpContext.Current.Request.UserAgent;
      userhostname = GetIPHost.HostName;
  </code></pre>
  
  <p>For user name I am tring to use</p>
  
  <pre><code>nametext = WindowsIdentity.GetCurrent().Name;
  //Shows server name when deployed on server 
  //when debuging and running localy shows correctly current user logged in
  
  //nametext = HttpContext.Current.Request.ServerVariables["LOGON_USER"]; 
  // not returning anything
  </code></pre>
  
  <p>I switched authentication and no results</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
  &lt;authentication mode="Windows"&gt;
  </code></pre>