Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CookieContainer.GetCookieHeader Method

Gets the HTTP cookie header that contains the HTTP cookies that represent the Cookie instances that are associated with a specific URI.

Namespace:  System.Net
Assemblies:   System (in System.dll)
  System.Net.Primitives (in System.Net.Primitives.dll)

public string GetCookieHeader(
	Uri uri
)

Parameters

uri
Type: System.Uri

The URI of the Cookie instances desired.

Return Value

Type: System.String
An HTTP cookie header, with strings representing Cookie instances delimited by semicolons.

ExceptionCondition
ArgumentNullException

uri is null.

GetCookieHeader returns a string that holds the HTTP cookie header for the Cookie instances specified by uri. The HTTP header is built by adding a string representation of each Cookie associated with uri. Note that the exact format of the string depends on the RFC that the Cookie conforms to. The strings for all the Cookie instances that are associated with uri are combined and delimited by semicolons.

This string is not in the correct format for use as the second parameter of the SetCookies method.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft