Mega Code Archive

 
Categories / C# Book / 08 Net
 

0588 CredentialCache

A credential cache contains one or more NetworkCredential objects, each keyed to a particular protocol and URI prefix. using System; using System.Net; using System.IO; using System.Linq; using System.Text; class Program { static void Main() { CredentialCache cache = new CredentialCache(); Uri prefix = new Uri("http://exchange.somedomain.com"); cache.Add(prefix, "Digest", new NetworkCredential("joe", "passwd")); cache.Add(prefix, "Negotiate", new NetworkCredential("joe", "passwd")); WebClient wc = new WebClient(); wc.Credentials = cache; } }