HttpCookiePairHeaderValueCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 HTTP 请求上的 Cookie HTTP 标头的值。
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
- 继承
- 属性
- 实现
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
以下示例代码演示了一个方法,该方法使用 HttpCookiePairHeaderValueCollection 和 HttpCookiePairHeaderValue 类的属性和方法获取和设置 HttpRequestMessage 对象上的 Cookie HTTP 标头。
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);
}
注解
HttpCookiePairHeaderValueCollection 类表示 HTTP 请求上的 Cookie HTTP 标头的值。
HttpCookiePairHeaderValueCollection 为用于 Cookie HTTP 标头中的 Cookie 信息的 HttpCookiePairHeaderValue 类的实例提供收集容器。
HttpRequestHeaderCollection 上的 Cookie 属性返回 HttpCookiePairHeaderValueCollection 对象
属性
Size |
获取集合中 HttpCookiePairHeaderValue 对象的数目。 |