HttpCookiePairHeaderValueCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents the value of the Cookie HTTP header on an HTTP request.
public ref class HttpCookiePairHeaderValueCollection sealed : IIterable<HttpCookiePairHeaderValue ^>, IVector<HttpCookiePairHeaderValue ^>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpCookiePairHeaderValueCollection final : IIterable<HttpCookiePairHeaderValue>, IVector<HttpCookiePairHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpCookiePairHeaderValueCollection final : IIterable<HttpCookiePairHeaderValue>, IVector<HttpCookiePairHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpCookiePairHeaderValueCollection : IEnumerable<HttpCookiePairHeaderValue>, IList<HttpCookiePairHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpCookiePairHeaderValueCollection : IEnumerable<HttpCookiePairHeaderValue>, IList<HttpCookiePairHeaderValue>, IStringable
Public NotInheritable Class HttpCookiePairHeaderValueCollection
Implements IEnumerable(Of HttpCookiePairHeaderValue), IList(Of HttpCookiePairHeaderValue), IStringable
- Inheritance
- Attributes
- Implements
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
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
Size |
Gets the number of HttpCookiePairHeaderValue objects in the collection. |
Methods
Append(HttpCookiePairHeaderValue) |
Adds a new HttpCookiePairHeaderValue item to the end of the collection. |
Clear() |
Removes all objects from the collection. |
First() |
Retrieves an iterator to the first HttpCookiePairHeaderValue item in the collection. |
GetAt(UInt32) |
Returns the HttpCookiePairHeaderValue at the specified index in the collection. |
GetMany(UInt32, HttpCookiePairHeaderValue[]) |
Retrieves the HttpCookiePairHeaderValue items that start at the specified index in the collection. |
GetView() |
Returns an immutable view of the HttpCookiePairHeaderValueCollection. |
IndexOf(HttpCookiePairHeaderValue, UInt32) |
Retrieves the index of an HttpCookiePairHeaderValue in the collection. |
InsertAt(UInt32, HttpCookiePairHeaderValue) |
Inserts an HttpCookiePairHeaderValue into the collection at the specified index. |
ParseAdd(String) |
Parses and adds an entry to the HttpCookiePairHeaderValueCollection. |
RemoveAt(UInt32) |
Removes the entry at the specified index from the HttpCookiePairHeaderValueCollection. |
RemoveAtEnd() |
Removes the last HttpCookiePairHeaderValue item from the collection. |
ReplaceAll(HttpCookiePairHeaderValue[]) |
Replaces all the HttpCookiePairHeaderValue items in the collection with the specified HttpCookiePairHeaderValue items. |
SetAt(UInt32, HttpCookiePairHeaderValue) |
Sets the HttpCookiePairHeaderValue at the specified index in the collection. |
ToString() |
Returns a string that represents the current HttpCookiePairHeaderValueCollection object. |
TryParseAdd(String) |
Tries to parse and add the specified item to the HttpCookiePairHeaderValueCollection. |