CredentialCache 构造函数

定义

创建 CredentialCache 类的新实例。

public:
 CredentialCache();
public CredentialCache ();
Public Sub New ()

示例

下面的代码示例使用多个安全凭据初始化 , CredentialCache 并将这些凭据与 一起使用 WebRequest

CredentialCache^ myCache = gcnew CredentialCache;

myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Basic", gcnew NetworkCredential( UserName,SecurelyStoredPassword ) );
myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Digest", gcnew 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.Credentials = myCache;
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

适用于