Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 2.38 KB

httpcookiepairheadervaluecollection.md

File metadata and controls

50 lines (34 loc) · 2.38 KB
-api-id -api-type
T:Windows.Web.Http.Headers.HttpCookiePairHeaderValueCollection
winrt class

Windows.Web.Http.Headers.HttpCookiePairHeaderValueCollection

-description

Represents the value of the Cookie HTTP header on an HTTP request.

-remarks

The HttpCookiePairHeaderValueCollection class represents the value of the Cookie HTTP header on an HTTP request.

The HttpCookiePairHeaderValueCollection provides a collection container for instances of the HttpCookiePairHeaderValue class used for cookie information in the Cookie HTTP header.

The Cookie property on the HttpRequestHeaderCollection returns an HttpCookiePairHeaderValueCollection object

-examples

The following sample code shows a method to get and set the Cookie HTTP header on an HttpRequestMessage object using the properties and methods on the HttpCookiePairHeaderValueCollection and HttpCookiePairHeaderValue classes.

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestCookie() {
            var request = new HttpRequestMessage();
            bool parsedOk = false;

            // Set the header with a string.
            parsedOk = request.Headers.Cookie.TryParseAdd("cookieName=cookieValue");

            // Set the header with a strong type.
            request.Headers.Cookie.Add(new HttpCookiePairHeaderValue("cookie2", "value2"));

            // Get the strong type out
            foreach (var value in request.Headers.Cookie) {
                System.Diagnostics.Debug.WriteLine("One of the Cookie values: {0}={1}", value.Name, value.Value);
            }

-see-also

IVector(HttpCookiePairHeaderValue), IIterable(HttpCookiePairHeaderValue), IStringable