HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection Class

Definition

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

public : sealed class HttpCookiePairHeaderValueCollection : IIterable<HttpCookiePairHeaderValue>, IVector<HttpCookiePairHeaderValue>, IStringable, IHttpCookiePairHeaderValueCollection
struct winrt::Windows::Web::Http::Headers::HttpCookiePairHeaderValueCollection : IIterable<HttpCookiePairHeaderValue>, IVector<HttpCookiePairHeaderValue>, IStringable, IHttpCookiePairHeaderValueCollection
public sealed class HttpCookiePairHeaderValueCollection : IEnumerable<HttpCookiePairHeaderValue>, IList<HttpCookiePairHeaderValue>, IStringable, IHttpCookiePairHeaderValueCollection
Public NotInheritable Class HttpCookiePairHeaderValueCollection Implements IEnumerable<HttpCookiePairHeaderValue>, IList<HttpCookiePairHeaderValue>, IStringable, IHttpCookiePairHeaderValueCollection
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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);
            }

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

Properties

Item[Int32] Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the element at the specified index.

Size Size Size Size Size

Gets the number of HttpCookiePairHeaderValue objects in the collection.

Methods

Append(HttpCookiePairHeaderValue) Append(HttpCookiePairHeaderValue) Append(HttpCookiePairHeaderValue) Append(HttpCookiePairHeaderValue) Append(HttpCookiePairHeaderValue)

Adds a new HttpCookiePairHeaderValue item to the end of the collection.

Clear() Clear() Clear() Clear() Clear()

Removes all objects from the collection.

First() First() First() First() First()

Retrieves an iterator to the first HttpCookiePairHeaderValue item in the collection.

GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Returns the HttpCookiePairHeaderValue at the specified index in the collection.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the collection.

GetMany(UInt32, HttpCookiePairHeaderValue[]) GetMany(UInt32, HttpCookiePairHeaderValue[]) GetMany(UInt32, HttpCookiePairHeaderValue[]) GetMany(UInt32, HttpCookiePairHeaderValue[]) GetMany(UInt32, HttpCookiePairHeaderValue[])

Retrieves the HttpCookiePairHeaderValue items that start at the specified index in the collection.

GetView() GetView() GetView() GetView() GetView()

Returns an immutable view of the HttpCookiePairHeaderValueCollection.

IndexOf(T) IndexOf(T) IndexOf(T) IndexOf(T) IndexOf(T)

Determines the index of a specific item in the System.Collections.Generic.IList`1.

IndexOf(HttpCookiePairHeaderValue, UInt32) IndexOf(HttpCookiePairHeaderValue, UInt32) IndexOf(HttpCookiePairHeaderValue, UInt32) IndexOf(HttpCookiePairHeaderValue, UInt32) IndexOf(HttpCookiePairHeaderValue, UInt32)

Retrieves the index of an HttpCookiePairHeaderValue in the collection.

Insert(Int32, T) Insert(Int32, T) Insert(Int32, T) Insert(Int32, T) Insert(Int32, T)

Inserts an item to the System.Collections.Generic.IList`1 at the specified index.

InsertAt(UInt32, HttpCookiePairHeaderValue) InsertAt(UInt32, HttpCookiePairHeaderValue) InsertAt(UInt32, HttpCookiePairHeaderValue) InsertAt(UInt32, HttpCookiePairHeaderValue) InsertAt(UInt32, HttpCookiePairHeaderValue)

Inserts an HttpCookiePairHeaderValue into the collection at the specified index.

ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String)

Parses and adds an entry to the HttpCookiePairHeaderValueCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the System.Collections.Generic.IList`1 item at the specified index.

RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32)

Removes the entry at the specified index from the HttpCookiePairHeaderValueCollection.

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last HttpCookiePairHeaderValue item from the collection.

ReplaceAll(HttpCookiePairHeaderValue[]) ReplaceAll(HttpCookiePairHeaderValue[]) ReplaceAll(HttpCookiePairHeaderValue[]) ReplaceAll(HttpCookiePairHeaderValue[]) ReplaceAll(HttpCookiePairHeaderValue[])

Replaces all the HttpCookiePairHeaderValue items in the collection with the specified HttpCookiePairHeaderValue items.

SetAt(UInt32, HttpCookiePairHeaderValue) SetAt(UInt32, HttpCookiePairHeaderValue) SetAt(UInt32, HttpCookiePairHeaderValue) SetAt(UInt32, HttpCookiePairHeaderValue) SetAt(UInt32, HttpCookiePairHeaderValue)

Sets the HttpCookiePairHeaderValue at the specified index in the collection.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpCookiePairHeaderValueCollection object.

TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String)

Tries to parse and add the specified item to the HttpCookiePairHeaderValueCollection.

See Also