HttpWebRequest.CookieContainer Property

 

Gets or sets the cookies associated with the request.

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

abstract CookieContainer : CookieContainer with get, set
override CookieContainer : CookieContainer with get, set

Property Value

Type: System.Net.CookieContainer

A CookieContainer that contains the cookies associated with this request.

The CookieContainer property provides an instance of the CookieContainer class that contains the cookies associated with this request.

CookieContainer is null by default. You must assign a CookieContainer object to the property to have cookies returned in the Cookies property of the HttpWebResponse returned by the GetResponse method.

System_CAPS_noteNote

For security reasons, cookies are disabled by default. If you want to use cookies, use the CookieContainer property to enable cookies.

The following code example sends a request to a URL and displays the cookies returned in the response.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: