CredentialCache Constructor
Collapse the table of content
Expand the table of content

CredentialCache Constructor

Creates a new instance of the CredentialCache class.

[Visual Basic]
Public Sub New()
[C#]
public CredentialCache();
[C++]
public: CredentialCache();
[JScript]
public function CredentialCache();

Remarks

The constructor creates a CredentialCache instance.

Example

[Visual Basic, C#, C++] The following example initializes a CredentialCache with multiple security credentials and uses those credentials with a WebRequest:

[Visual Basic] 
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

[C#] 
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;

[C++] 
CredentialCache* myCache = new CredentialCache();

myCache->Add(new Uri(S"http://www.contoso.com/"),S"Basic",new NetworkCredential(UserName,SecurelyStoredPassword));
myCache->Add(new Uri(S"http://www.contoso.com/"),S"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain));

wReq->Credentials = myCache;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

CredentialCache Class | CredentialCache Members | System.Net Namespace

Show:
© 2016 Microsoft