Provides a container for a collection of CookieCollection objects.
Assemblies: System.Net.Primitives (in System.Net.Primitives.dll)
System (in System.dll)
Thetype exposes the following members.
|CookieContainer()||Initializes a new instance of the class.|
|CookieContainer(Int32)||Initializes a new instance of the class with a specified value for the number of Cookie instances that the container can hold.|
|CookieContainer(Int32, Int32, Int32)||Initializes a new instance of the class with specific properties.|
|Capacity||Gets and sets the number of Cookie instances that a can hold.|
|Count||Gets the number of Cookie instances that a currently holds.|
|MaxCookieSize||Represents the maximum allowed length of a Cookie.|
|PerDomainCapacity||Gets and sets the number of Cookie instances that a can hold per domain.|
|Add(Cookie)||Adds a Cookie to a . This method uses the domain from the Cookie to determine which domain collection to associate the Cookie with.|
|Add(CookieCollection)||Adds the contents of a CookieCollection to the .|
|Add(Uri, Cookie)||Adds a Cookie to the for a particular URI.|
|Add(Uri, CookieCollection)||Adds the contents of a CookieCollection to the for a particular URI.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetCookieHeader||Gets the HTTP cookie header that contains the HTTP cookies that represent the Cookie instances that are associated with a specific URI.|
|GetCookies||Gets a CookieCollection that contains the Cookie instances that are associated with a specific URI.|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|SetCookies||Adds Cookie instances for one or more cookies from an HTTP cookie header to the for a specific URI.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|DefaultCookieLengthLimit||Represents the default maximum size, in bytes, of the Cookie instances that the can hold. This field is constant.|
|DefaultCookieLimit||Represents the default maximum number of Cookie instances that the can hold. This field is constant.|
|DefaultPerDomainCookieLimit||Represents the default maximum number of Cookie instances that the can reference per domain. This field is constant.|
A is a data structure that provides storage for instances of the Cookie class, and which is accessed in a database-like manner. The has a capacity limit that is set when the container is created or changed by a property.
An instance of the Cookie class is added to the container based on its originating URI. It is added to an internal CookieCollection associated with the URI. A Cookie is retrieved from the container based on the URI as a CookieCollection, or as a string that can be used to submit HTTP WebRequests.
The has three properties that govern the volume of the content of the container: Capacity, MaxCookieSize, and PerDomainCapacity. These values have the default settings of 300, 4096, and 20 respectively. When a Cookie is added to the container, these properties are used to determine whether a Cookie already contained in the should be discarded to make room for the new one. The keeps track of each addition to ensure that neither the Capacity nor the PerDomainCapacity limits are exceeded. If one or both are exceeded, then Cookie instances held by the are removed. First, any expired Cookie is removed. If further capacity must be recaptured, then the least-recently used CookieCollection is purged.
.NET FrameworkSupported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.