HttpChallengeHeaderValueCollection 類別

定義

表示 HTTP 回應上的 Proxy-AuthenticateWWW-Authenticate HTTP 標頭的值。

public ref class HttpChallengeHeaderValueCollection sealed : IIterable<HttpChallengeHeaderValue ^>, IVector<HttpChallengeHeaderValue ^>, 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 HttpChallengeHeaderValueCollection final : IIterable<HttpChallengeHeaderValue>, IVector<HttpChallengeHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpChallengeHeaderValueCollection final : IIterable<HttpChallengeHeaderValue>, IVector<HttpChallengeHeaderValue>, 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 HttpChallengeHeaderValueCollection : IEnumerable<HttpChallengeHeaderValue>, IList<HttpChallengeHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpChallengeHeaderValueCollection : IEnumerable<HttpChallengeHeaderValue>, IList<HttpChallengeHeaderValue>, IStringable
Public NotInheritable Class HttpChallengeHeaderValueCollection
Implements IEnumerable(Of HttpChallengeHeaderValue), IList(Of HttpChallengeHeaderValue), IStringable
繼承
Object Platform::Object IInspectable HttpChallengeHeaderValueCollection
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例程式碼示範使用 HttpChallengeHeaderValueCollection 和HttpChallengeHeaderValue類別的屬性和方法,在HttpResponseMessage物件上取得和設定Proxy-Authenticate HTTP 標頭的方法。

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderResponseProxyAuthenticate() {
            var response = new HttpResponseMessage();

            // Set the header with a strong type.
            response.Headers.ProxyAuthenticate.TryParseAdd("Basic");
            response.Headers.ProxyAuthenticate.Add(new HttpChallengeHeaderValue("authScheme", "authToken"));

            // Get the strong type out
            foreach (var value in response.Headers.ProxyAuthenticate) {
                System.Diagnostics.Debug.WriteLine("Proxy authenticate scheme and token: {0} {1}", value.Scheme, value.Token);
            }

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The ProxyAuthenticate ToString() results: {0}", response.Headers.ProxyAuthenticate.ToString());
        }

備註

HttpChallengeHeaderValueCollection 代表 HTTP 回應上的 Proxy-AuthenticateWWW-Authenticate HTTP 標頭的值。

HttpChallengeHeaderValueCollection 提供 HttpChallengeHeaderValue 類別實例的集合容器,用於 授權ProxyAuthorizationWWW-AuthenticationProxy 驗證 HTTP 標頭值中使用的驗證資訊。

HttpResponseHeaderCollection上的ProxyAuthenticate屬性會傳回 HttpChallengeHeaderValueCollection 物件。 HttpResponseHeaderCollection上的WwwAuthenticate屬性也會傳回 HttpChallengeHeaderValueCollection 物件。

集合成員清單

針對 JavaScript,HttpChallengeHeaderValueCollection 具有成員清單中顯示的成員。 此外,HttpChallengeHeaderValueCollection 支援 Array.prototype 的成員,並使用索引來存取專案。

列舉 C# 或 Microsoft Visual Basic 中的集合

您可以在 C# 或 Microsoft Visual Basic 中逐一查看 HttpChallengeHeaderValueCollection 物件。 在許多情況下,例如使用 foreach 語法,編譯器會為您執行此轉換,而且您不需要明確地轉換成 IEnumerable<HttpChallengeHeaderValue> 。 如果您需要明確轉換,例如,如果您想要呼叫GetEnumerator,請使用HttpChallengeHeaderValue條件約束將集合物件轉換成IEnumerable < T >

屬性

Size

取得集合中的 HttpChallengeHeaderValue 物件數目。

方法

Append(HttpChallengeHeaderValue)

將新的 HttpChallengeHeaderValue 專案新增至集合結尾。

Clear()

從集合中移除所有 HttpChallengeHeaderValue 物件。

First()

擷取反覆運算器至集合中的第一個 HttpChallengeHeaderValue 專案。

GetAt(UInt32)

傳回集合中指定索引處的 HttpChallengeHeaderValue

GetMany(UInt32, HttpChallengeHeaderValue[])

擷取從集合中指定索引開始的 HttpChallengeHeaderValue 專案。

GetView()

會傳回 HttpChallengeHeaderValueCollection的不可變檢視。

IndexOf(HttpChallengeHeaderValue, UInt32)

擷取集合中 HttpChallengeHeaderValue 的索引。

InsertAt(UInt32, HttpChallengeHeaderValue)

HttpChallengeHeaderValue 插入集合中指定的索引處。

ParseAdd(String)

剖析並將專案新增至 HttpChallengeHeaderValueCollection

RemoveAt(UInt32)

HttpChallengeHeaderValueCollection移除位於指定索引處的專案。

RemoveAtEnd()

從集合中移除最後一個 HttpChallengeHeaderValue 專案。

ReplaceAll(HttpChallengeHeaderValue[])

以指定的HttpChallengeHeaderValue 專案取代集合中的所有 HttpChallengeHeaderValue專案。

SetAt(UInt32, HttpChallengeHeaderValue)

在集合中指定的索引處設定 HttpChallengeHeaderValue

ToString()

會傳回字串,表示目前的 HttpChallengeHeaderValueCollection 物件。

TryParseAdd(String)

嘗試剖析並將指定的專案新增至 HttpChallengeHeaderValueCollection

適用於

另請參閱