HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection HttpCookiePairHeaderValueCollection Class

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

Syntax

Declaration

public sealed class HttpCookiePairHeaderValueCollectionpublic sealed class HttpCookiePairHeaderValueCollectionPublic NotInheritable Class HttpCookiePairHeaderValueCollection

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

Properties summary

Gets the number of HttpCookiePairHeaderValue objects in the collection.

Methods summary

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

Removes all objects from the collection.

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

Returns the HttpCookiePairHeaderValue at the specified index in the collection.

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

Returns an immutable view of the HttpCookiePairHeaderValueCollection.

Retrieves the index of an HttpCookiePairHeaderValue in the collection.

Inserts an HttpCookiePairHeaderValue into the collection at the specified index.

Parses and adds an entry to the HttpCookiePairHeaderValueCollection.

Removes the entry at the specified index from the HttpCookiePairHeaderValueCollection.

Removes the last HttpCookiePairHeaderValue item from the collection.

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

Sets the HttpCookiePairHeaderValue at the specified index in the collection.

Returns a string that represents the current HttpCookiePairHeaderValueCollection object.

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

Properties

Methods

  • Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue)

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

    public void Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)public void Append(Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)Public Function Append(value As Windows.Web.Http.Headers.HttpCookiePairHeaderValue) As void

    Parameters

  • Clear()
    Clear()
    Clear()
    Clear()

    Removes all objects from the collection.

    public void Clear()public void Clear()Public Function Clear() As void
  • First()
    First()
    First()
    First()

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

    public IIterator<HttpCookiePairHeaderValue> First()public IIterator<HttpCookiePairHeaderValue> First()Public Function First() As IIterator( Of HttpCookiePairHeaderValue )

    Returns

  • GetAt(System.UInt32)
    GetAt(System.UInt32)
    GetAt(System.UInt32)
    GetAt(System.UInt32)

    Returns the HttpCookiePairHeaderValue at the specified index in the collection.

    public HttpCookiePairHeaderValue GetAt(System.UInt32 index)public HttpCookiePairHeaderValue GetAt(System.UInt32 index)Public Function GetAt(index As System.UInt32) As HttpCookiePairHeaderValue

    Parameters

    • index
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The zero-based index of a specified item in the collection.

    Returns

  • GetMany(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    GetMany(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    GetMany(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    GetMany(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])

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

    public uint GetMany(System.UInt32 startIndex,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[] items)public uint GetMany(System.UInt32 startIndex,Windows.Web.Http.Headers.HttpCookiePairHeaderValue[] items)Public Function GetMany(startIndex As System.UInt32,items As Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]) As uint

    Parameters

    Returns

  • GetView()
    GetView()
    GetView()
    GetView()

    Returns an immutable view of the HttpCookiePairHeaderValueCollection.

    public IVectorView<HttpCookiePairHeaderValue> GetView()public IVectorView<HttpCookiePairHeaderValue> GetView()Public Function GetView() As IVectorView( Of HttpCookiePairHeaderValue )

    Returns

  • IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue,System.UInt32)
    IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue,System.UInt32)
    IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue,System.UInt32)
    IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue,System.UInt32)

    Retrieves the index of an HttpCookiePairHeaderValue in the collection.

    public bool IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue value,System.UInt32 index)public bool IndexOf(Windows.Web.Http.Headers.HttpCookiePairHeaderValue value,System.UInt32 index)Public Function IndexOf(value As Windows.Web.Http.Headers.HttpCookiePairHeaderValue,index As System.UInt32) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Indicates whether the item is found.

      true if the HttpCookiePairHeaderValue item is found; otherwise, false.

  • InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)

    Inserts an HttpCookiePairHeaderValue into the collection at the specified index.

    public void InsertAt(System.UInt32 index,Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)public void InsertAt(System.UInt32 index,Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)Public Function InsertAt(index As System.UInt32,value As Windows.Web.Http.Headers.HttpCookiePairHeaderValue) As void

    Parameters

  • ParseAdd(System.String)
    ParseAdd(System.String)
    ParseAdd(System.String)
    ParseAdd(System.String)

    Parses and adds an entry to the HttpCookiePairHeaderValueCollection.

    public void ParseAdd(System.String input)public void ParseAdd(System.String input)Public Function ParseAdd(input As System.String) As void

    Parameters

    • input
      System.String
      System.String
      System.String
      System.String

      The entry to add.

  • RemoveAt(System.UInt32)
    RemoveAt(System.UInt32)
    RemoveAt(System.UInt32)
    RemoveAt(System.UInt32)

    Removes the entry at the specified index from the HttpCookiePairHeaderValueCollection.

    public void RemoveAt(System.UInt32 index)public void RemoveAt(System.UInt32 index)Public Function RemoveAt(index As System.UInt32) As void

    Parameters

    • index
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The index of the entry to remove.

  • RemoveAtEnd()
    RemoveAtEnd()
    RemoveAtEnd()
    RemoveAtEnd()

    Removes the last HttpCookiePairHeaderValue item from the collection.

    public void RemoveAtEnd()public void RemoveAtEnd()Public Function RemoveAtEnd() As void
  • ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[])

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

    public void ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[] items)public void ReplaceAll(Windows.Web.Http.Headers.HttpCookiePairHeaderValue[] items)Public Function ReplaceAll(items As Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]) As void

    Parameters

    • items
      Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]
      Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]
      Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]
      Windows.Web.Http.Headers.HttpCookiePairHeaderValue[]

      The HttpCookiePairHeaderValue items to add to the collection.

  • SetAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    SetAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    SetAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)
    SetAt(System.UInt32,Windows.Web.Http.Headers.HttpCookiePairHeaderValue)

    Sets the HttpCookiePairHeaderValue at the specified index in the collection.

    public void SetAt(System.UInt32 index,Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)public void SetAt(System.UInt32 index,Windows.Web.Http.Headers.HttpCookiePairHeaderValue value)Public Function SetAt(index As System.UInt32,value As Windows.Web.Http.Headers.HttpCookiePairHeaderValue) As void

    Parameters

  • ToString()
    ToString()
    ToString()
    ToString()

    Returns a string that represents the current HttpCookiePairHeaderValueCollection object.

    public string ToString()public string ToString()Public Function ToString() As string

    Returns

    • string
      string
      string
      string

      A string that represents the current object.

  • TryParseAdd(System.String)
    TryParseAdd(System.String)
    TryParseAdd(System.String)
    TryParseAdd(System.String)

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

    public bool TryParseAdd(System.String input)public bool TryParseAdd(System.String input)Public Function TryParseAdd(input As System.String) As bool

    Parameters

    • input
      System.String
      System.String
      System.String
      System.String

      The item to parse and add.

    Returns

    • bool
      bool
      bool
      bool

      true if the item successfully parsed and was added; otherwise false.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Web.Http.Headers.dll