Assembly: System (in system.dll)
'Declaration Public Class CredentialCache Implements ICredentials, ICredentialsByHost, IEnumerable 'Usage Dim instance As CredentialCache
The CredentialCache class stores credentials for multiple Internet resources. Applications that need to access multiple resources can store the credentials for those resources in a CredentialCache instance that then provides the proper set of credentials to the Internet resource when required. When the GetCredential method is called, it compares the Uniform Resource Identifier (URI) and authentication type provided with those stored in the cache and returns the first set of credentials that match.
The DefaultCredentials property contains the system credentials of the current security context. For client applications, these represent the user name, password, and domain of the user who is currently logged in. For ASP.NET applications, the default credentials are the user credentials of the logged-in user or the user being impersonated.
The following code example initializes a CredentialCache with multiple security credentials and uses those credentials with a WebRequest.
Dim myCache As New CredentialCache() myCache.Add(New Uri("http://www.contoso.com/"), "Basic", New NetworkCredential(UserName, SecurelyStoredPassword)) myCache.Add(New Uri("http://www.contoso.com/"), "Digest", New NetworkCredential(UserName, SecurelyStoredPassword, Domain)) wReq.Credentials = myCache
CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("http://www.contoso.com/"), "Basic", new NetworkCredential(userName, securelyStoredPassword)); myCache.Add(new Uri("http://www.contoso.com/"), "Digest", new NetworkCredential(userName, securelyStoredPassword, domain)); wReq.set_Credentials(myCache);
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.