public class CredentialCache : ICredentials, IEnumerable
|
The CredentialCache.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.
CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("http://www.contoso.com/"),"Basic",new NetworkCredential("myUser","myPass")); myCache.Add(new Uri("http://www.contoso.com/"),"Digest", new NetworkCredential("myUser","myPass","myDomain")); wReq.Credentials = myCache;
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Creates a new instance of the CredentialCache class. |
DefaultCredentials | Read-only Gets the system credentials of the application. |
Add | Adds a NetworkCredential instance to the credential cache. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetCredential | Returns the NetworkCredential instance associated with the specified URI and authentication type. |
GetEnumerator | Returns an enumerator that can iterate through the CredentialCache instance. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
Remove | Deletes a NetworkCredential instance from the cache. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public CredentialCache(); |
Use the CredentialCache.Add method to add additional credentials to the CredentialCache instance.
CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("http://www.contoso.com/"),"Basic",new NetworkCredential("myUser","myPass")); myCache.Add(new Uri("http://www.contoso.com/"),"Digest", new NetworkCredential("myUser","myPass","myDomain")); wReq.Credentials = myCache;
public static ICredentials DefaultCredentials {get;}
|
CredentialCache.DefaultCredentials represents the system credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application. For ASP.NET applications, the default credentials are the user credentials of the logged-in user, or the user being impersonated.
public void Add( |
uriPrefix
authType
cred
Exception Type | Condition |
---|---|
ArgumentNullException | uriPrefix is null -or- authType is null. |
ArgumentException | The same credentials are added more than once. |
CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("http://www.contoso.com/"),"Basic",new NetworkCredential("myUser","myPass")); myCache.Add(new Uri("http://www.contoso.com/"),"Digest", new NetworkCredential("myUser","myPass","myDomain")); wReq.Credentials = myCache;
~CredentialCache(); |
public NetworkCredential GetCredential( |
uriPrefix
authType
CredentialCache.GetCredential uses the longest matching URI prefix in the cache to determine which set of credentials to return for an authorization type. The following table shows examples.
URI Prefix | Matches |
---|---|
http://www.contoso.com/portal/news.htm | Requests for the specific Web page news.htm . |
http://www.contoso.com/portal/ | Requests for all content in the portal path, except the page news.htm . |
http://www.contoso.com/ | Requests for all resources at www.contoso.com , except those in the portal path. |
public IEnumerator GetEnumerator(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
uriPrefix
authType
public virtual string ToString(); |