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 HttpCookiePairHeaderValueCollectionpublic sealed 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(HttpCookiePairHeaderValue)
    Append(HttpCookiePairHeaderValue)
    Append(HttpCookiePairHeaderValue)
    Append(HttpCookiePairHeaderValue)

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

    public void Append(HttpCookiePairHeaderValue value)public void Append(HttpCookiePairHeaderValue value)Public Function Append(value As HttpCookiePairHeaderValue) As voidpublic void Append(HttpCookiePairHeaderValue value)

    Parameters

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

    Removes all objects from the collection.

    public void Clear()public void Clear()Public Function Clear() As voidpublic void Clear()
  • 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 )public IIterator<HttpCookiePairHeaderValue> First()

    Returns

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

    Returns the HttpCookiePairHeaderValue at the specified index in the collection.

    public HttpCookiePairHeaderValue GetAt(UInt32 index)public HttpCookiePairHeaderValue GetAt(UInt32 index)Public Function GetAt(index As UInt32) As HttpCookiePairHeaderValuepublic HttpCookiePairHeaderValue GetAt(UInt32 index)

    Parameters

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

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

    Returns

  • 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.

    public uint GetMany(UInt32 startIndex, HttpCookiePairHeaderValue[] items)public uint GetMany(UInt32 startIndex, HttpCookiePairHeaderValue[] items)Public Function GetMany(startIndex As UInt32, items As HttpCookiePairHeaderValue[]) As uintpublic uint GetMany(UInt32 startIndex, HttpCookiePairHeaderValue[] items)

    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 )public IVectorView<HttpCookiePairHeaderValue> GetView()

    Returns

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

    Retrieves the index of an HttpCookiePairHeaderValue in the collection.

    public bool IndexOf(HttpCookiePairHeaderValue value, UInt32 index)public bool IndexOf(HttpCookiePairHeaderValue value, UInt32 index)Public Function IndexOf(value As HttpCookiePairHeaderValue, index As UInt32) As boolpublic bool IndexOf(HttpCookiePairHeaderValue value, UInt32 index)

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Indicates whether the item is found.

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

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

    Inserts an HttpCookiePairHeaderValue into the collection at the specified index.

    public void InsertAt(UInt32 index, HttpCookiePairHeaderValue value)public void InsertAt(UInt32 index, HttpCookiePairHeaderValue value)Public Function InsertAt(index As UInt32, value As HttpCookiePairHeaderValue) As voidpublic void InsertAt(UInt32 index, HttpCookiePairHeaderValue value)

    Parameters

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

    Parses and adds an entry to the HttpCookiePairHeaderValueCollection.

    public void ParseAdd(String input)public void ParseAdd(String input)Public Function ParseAdd(input As String) As voidpublic void ParseAdd(String input)

    Parameters

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

      The entry to add.

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

    Removes the entry at the specified index from the HttpCookiePairHeaderValueCollection.

    public void RemoveAt(UInt32 index)public void RemoveAt(UInt32 index)Public Function RemoveAt(index As UInt32) As voidpublic void RemoveAt(UInt32 index)

    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 voidpublic void RemoveAtEnd()
  • ReplaceAll(HttpCookiePairHeaderValue[])
    ReplaceAll(HttpCookiePairHeaderValue[])
    ReplaceAll(HttpCookiePairHeaderValue[])
    ReplaceAll(HttpCookiePairHeaderValue[])

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

    public void ReplaceAll(HttpCookiePairHeaderValue[] items)public void ReplaceAll(HttpCookiePairHeaderValue[] items)Public Function ReplaceAll(items As HttpCookiePairHeaderValue[]) As voidpublic void ReplaceAll(HttpCookiePairHeaderValue[] items)

    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(UInt32, HttpCookiePairHeaderValue)
    SetAt(UInt32, HttpCookiePairHeaderValue)
    SetAt(UInt32, HttpCookiePairHeaderValue)
    SetAt(UInt32, HttpCookiePairHeaderValue)

    Sets the HttpCookiePairHeaderValue at the specified index in the collection.

    public void SetAt(UInt32 index, HttpCookiePairHeaderValue value)public void SetAt(UInt32 index, HttpCookiePairHeaderValue value)Public Function SetAt(index As UInt32, value As HttpCookiePairHeaderValue) As voidpublic void SetAt(UInt32 index, HttpCookiePairHeaderValue value)

    Parameters

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

    Returns a string that represents the current HttpCookiePairHeaderValueCollection object.

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

    Returns

    • string
      string
      string
      string

      A string that represents the current object.

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

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

    public bool TryParseAdd(String input)public bool TryParseAdd(String input)Public Function TryParseAdd(input As String) As boolpublic bool TryParseAdd(String input)

    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.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Web.Http.Headers.dll