Add Method (Uri, Cookie)
Collapse the table of content
Expand the table of content

CookieContainer.Add Method (Uri, Cookie)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Adds the specified Cookie with the specified Uniform Resource Identifier (URI) to this CookieContainer.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)

public void Add(
	Uri uri,
	Cookie cookie
)

Parameters

uri
Type: System.Uri
The URI of the cookie to add to this CookieContainer.
cookie
Type: System.Net.Cookie
The Cookie to add to this CookieContainer.

ExceptionCondition
ArgumentNullException

cookie is null.

ArgumentException

The domain for cookie is null.

CookieException

cookie is larger than MaxCookieSize.

-or-

the domain for cookie is not a valid URI.

If the specified cookie already exists in the container, then the cookie will be overwritten.

The following example shows how to use the Add method.


request.CookieContainer.Add(new Uri("http://windowsteamblog.com/windows_phone/b/windowsphone/rss.aspx"),
    new Cookie("id", "1234"));


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft