Export (0) Print
Expand All

CookieContainer.Capacity Property

Gets and sets the number of Cookie instances a CookieContainer can hold.

[Visual Basic]
Public Property Capacity As Integer
[C#]
public int Capacity {get; set;}
[C++]
public: __property int get_Capacity();
public: __property void set_Capacity(int);
[JScript]
public function get Capacity() : int;
public function set Capacity(int);

Property Value

The number of Cookie instances a CookieContainer can hold. This is a hard limit and cannot be exceeded by adding a Cookie.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException Capacity is less than or equal to zero or (value is less than PerDomainCapacity and PerDomainCapacity is not equal to MaxValue).

Remarks

If Count equals or exceeds Capacity, one or more Cookie instances are removed from the container. Enough instances are removed to bring Count below Capacity as follows: if there are expired Cookie instances in scope they are cleaned up. If not, then the least recently used CookieCollection is found and removed from the container.

Capacity must be greater than or equal to PerDomainCapacity. If you set PerDomainCapacity and the current Count of Cookie instances is less than the new value, the excess is removed from the container. Enough instances are removed to bring Count below Capacity as follows: if there are expired Cookie instances in scope they are cleaned up. If not, or if there are still more than the new value of PerDomainCapacity, then the least recently used CookieCollection is found and removed from the container.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

CookieContainer Class | CookieContainer Members | System.Net Namespace | Cookie | CookieCollection | CookieContainer | CookieException

Show:
© 2014 Microsoft