O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

CredentialCache

Synopsis

This class maintains credentials for multiple network resources. If you are developing a client application that needs to authenticate itself to more than one server, you can store an instance of this class in the WebRequest.Credentials property.

After you create an instance of this class, use the Add() method to associate NetworkCredential objects with a URI and authentication type (using a string such as "Basic" or "Digest"). Then you can assign the CredentialCache instance to the WebRequest.Credentials property to use the credentials for future web requests.

public class CredentialCache : ICredentials, IEnumerable {
// Public Constructors
   public method CredentialCache();  
// Public Static Properties
   public static field ICredentials DefaultCredentials{get; } 
// Public Instance Methods
   public method void Add(Uri uriPrefix, string authType, 
        NetworkCredential cred);  
   public method NetworkCredential GetCredential(               // implements ICredentials
        Uri uriPrefix, string authType);  
   public method IEnumerator GetEnumerator();                    // implements IEnumerable
   public method void Remove(Uri uriPrefix, string authType);  
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required