title: NetworkCredential error in ASP.NET
body: <p>I am trying to access a webpage through ASP.NET using the NetworkCredential class. However I keep getting an exception with the following message <code>System.Security.Cryptography.CryptographicException: The handle is invalid</code> </p>
  
  <p>Below is my code on how I am trying to call the function. Any help is greatly appreciated.</p>
  
  <p>C#:</p>
  
  <pre><code>System.Net.WebClient client = new System.Net.WebClient();
  client.Credentials = new System.Net.NetworkCredential("Admin", "Nimda");
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>[CryptographicException: The handle is invalid.
  ]
  
  System.Security.SecureString.ProtectMemory() +154
     System.Security.SecureString.InitializeSecureString(Char* value, Int32 length) +170
     System.Security.SecureString..ctor(Char* value, Int32 length) +65
     System.Net.SecureStringHelper.CreateSecureString(String plainString) +6181188
     System.Net.NetworkCredential..ctor(String userName, String password) +64
  </code></pre>