Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CredentialCache Constructor
Collapse the table of content
Expand the table of content

CredentialCache Constructor

Creates a new instance of the CredentialCache class.

Namespace:  System.Net
Assemblies:   System (in System.dll)
  System.Net.Primitives (in System.Net.Primitives.dll)

public CredentialCache()

The constructor creates a CredentialCache instance.

The following code example initializes a CredentialCache with multiple security credentials and uses those credentials with a WebRequest.

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.Credentials = myCache;

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8
Show:
© 2015 Microsoft