CookieContainer.PerDomainCapacity 屬性


取得或設定 CookieContainer 在每一個網域可以保留的 Cookie 執行個體數目。Gets or sets the number of Cookie instances that a CookieContainer can hold per domain.

 property int PerDomainCapacity { int get(); };
public int PerDomainCapacity { get; }
member this.PerDomainCapacity : int
Public ReadOnly Property PerDomainCapacity As Integer


每一個網域允許的 Cookie 執行個體數目。The number of Cookie instances that are allowed per domain.


PerDomainCapacity 小於或等於零。PerDomainCapacity is less than or equal to zero.

-或--or- (PerDomainCapacity 大於 Cookie 執行個體允許的最大數目 300 且不等於 MaxValue)。(PerDomainCapacity is greater than the maximum allowable number of cookies instances, 300, and is not equal to MaxValue).


如果新PerDomainCapacity的值小於目前的值,而且任何定義域集合包含比新值更多Cookie的實例,則會剪除集合以配合。If the new PerDomainCapacity value is less than the current value, and if any of the domain collections contain more Cookie instances than the new value, the collections are pruned to fit. 這會使用與Capacity屬性中所述相同的基本規則。This uses the same basic rules as described in the Capacity property. 不過,這只會在此網域的集合上進行清除。However, this does the clean-up only on the collection for this domain.