title: System.Security.Principal.WindowsIdentity.GetCurrent().Name is Works
body: <p>I am using <code>System.Security.Principal.WindowsIdentity.GetCurrent().Name</code> (with windows authentication in my web.config) to get the client username.</p>
  
  <p>My question is whether this code works when I put the page onto the intranet, because I need to store the username within the session for later use.</p>
  
  <p>Will I be able to get the username the user used to log into my page using this code?</p>
  
  <pre><code>void Authenticate()
  {
      string strLogin = null;
  
      try
      {
          strLogin = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
          Session.Add("Login", strLogin);
          //Label1.Text = strLogin;
          //Label2.Text = System.Environment.UserName;
      }
      catch (Exception ex)
      {
          Response.Write(strLogin);
          Response.Write("&lt;br/&gt;handled:" + ex.Message.ToString());
          Response.End();
      }
      finally
      {
          GC.Collect();
      }
  }
  </code></pre>