System.Net.CookieContainer.Add Method

Adds a System.Net.Cookie to the System.Net.CookieContainer for a particular URI.

Syntax

public void Add (Uri uri, Cookie cookie)

Parameters

uri
The URI of the System.Net.Cookie to be added to the System.Net.CookieContainer.
cookie
The System.Net.Cookie 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 the Cookie.Version property of a System.Net.Cookie is Netscape, the Cookie.Path property of the System.Net.Cookie, if not set explicitly, is derived from the URI and is the complete path from the URI, including the page name.

If the CookieContainer.Count property equals the CookieContainer.Capacity property, one or more System.Net.Cookie instances are 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