System.Net.CookieContainer.Add Method

Adds the contents of a System.Net.CookieCollection to the System.Net.CookieContainer for a particular URI.

Syntax

public void Add (Uri uri, CookieCollection cookies)

Parameters

uri
The URI of the System.Net.CookieCollection to be added to the System.Net.CookieContainer.
cookies
The System.Net.CookieCollection to be added to the System.Net.CookieContainer.

Remarks

If you add a System.Net.Cookie instance for just one specific host, do not set the Cookie.Domain property of the System.Net.Cookie instance. This is set automatically, based on the URI.

If your URI corresponds to your local domain and sends to all the hosts on the local domain, set the System.Net.Cookie Cookie.Domain property equal to ".local". Otherwise, make sure it matches the host name used in the URI.

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

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0