title: ASP.NET Authentication Troubleshooting
body: <p>I have a fairly complex web app that was built (by a contractor) to use integrated authentication.  As part of the authentication process, a <code>GetNetworkID()</code> function is used that looks like this:</p>
  
  <pre><code>private string GetNetworkID()
  {
      return HttpContext.Current.User.Identity.Name.Split(new char[] { '\\' })[1];
  }
  </code></pre>
  
  <p>When I run this on my development box, the <code>HttpContext.Current.User.Identity.Name</code> value is 
  <em>myNetwork\\myUserID</em>, so the above funciton returns my User ID, as intended, and the authenticaiton process works just fine.</p>
  
  <p>But when I run this on my web server, I get an <em>Index was outside the bounds of the array</em> error thrown by the return statement in the <code>GetNetworkID()</code> function.</p>
  
  <p>I'm a bit lost on how to troubleshoot this and how to figure out if it's an IIS configuration issue (my web server is a Windows Server 2008 box running IIS 7), or something else.</p>
  
  <p>If I hard-code my User ID as the return value for the <code>GetNetworkID()</code> function, it works on the web server, but I don't have any great ideas about how to debug on the web server to determine what the <code>HttpContext.Current.User.Identity.Name</code> return value is that's causing the array index error.</p>
  
  <p>Any suggestions?</p>