HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection Class

Represents the value of the Proxy-Authenticate or WWW-Authenticate HTTP header on an HTTP response.

Syntax

Declaration

public sealed class HttpChallengeHeaderValueCollectionpublic sealed class HttpChallengeHeaderValueCollectionPublic NotInheritable Class HttpChallengeHeaderValueCollection

Remarks

The HttpChallengeHeaderValueCollection represents the value of the Proxy-Authenticate or WWW-Authenticate HTTP header on an HTTP response.

The HttpChallengeHeaderValueCollection provides a collection container for instances of the HttpChallengeHeaderValue class used for authentication information used in the Authorization, ProxyAuthorization, WWW-Authenticate, and Proxy-Authenticate HTTP header values.

The ProxyAuthenticate property on HttpResponseHeaderCollection returns an HttpChallengeHeaderValueCollection object. The WwwAuthenticate property on HttpResponseHeaderCollection also returns an HttpChallengeHeaderValueCollection object.

Collection member lists

For JavaScript, HttpChallengeHeaderValueCollection has the members shown in the member lists. In addition, HttpChallengeHeaderValueCollection supports members of Array.prototype and using an index to access items.

Enumerating the collection in C# or Microsoft Visual Basic

You can iterate through an HttpChallengeHeaderValueCollection object in C# or Microsoft Visual Basic. In many cases, such as using foreach syntax, the compiler does this casting for you and you won't need to cast to IEnumerable<HttpChallengeHeaderValue> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast the collection object to IEnumerable<T> with an HttpChallengeHeaderValue constraint.

Examples

The following sample code shows a method to get and set the Proxy-Authenticate HTTP header on an HttpResponseMessage object using the properties and methods on the HttpChallengeHeaderValueCollection and HttpChallengeHeaderValue classes.

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

Properties summary

Gets the number of HttpChallengeHeaderValue objects in the collection.

Methods summary

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

Removes all HttpChallengeHeaderValue objects from the collection.

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

Returns the HttpChallengeHeaderValue at the specified index in the collection.

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

Returns an immutable view of the HttpChallengeHeaderValueCollection.

Retrieves the index of an HttpChallengeHeaderValue in the collection.

Inserts an HttpChallengeHeaderValue into the collection at the specified index.

Parses and adds an entry to the HttpChallengeHeaderValueCollection.

Removes the entry at the specified index from the HttpChallengeHeaderValueCollection.

Removes the last HttpChallengeHeaderValue item from the collection.

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

Sets the HttpChallengeHeaderValue at the specified index in the collection.

Returns a string that represents the current HttpChallengeHeaderValueCollection object.

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

Properties

Methods

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

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

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

    Parameters

    Remarks

    After you've added an item, you can use the IndexOf(Windows.Web.Http.Headers.HttpChallengeHeaderValue,System.UInt32) method to get it by index.

    To add an item to a position in the collection that's not at the collection end, use the InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue) method.

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is Add.

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

    Removes all HttpChallengeHeaderValue 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 HttpChallengeHeaderValue item in the collection.

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

    Returns

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

    Returns the HttpChallengeHeaderValue at the specified index in the collection.

    public HttpChallengeHeaderValue GetAt(System.UInt32)public HttpChallengeHeaderValue GetAt(System.UInt32)Public Function GetAt(System.UInt32) As HttpChallengeHeaderValue

    Parameters

    Returns

    Remarks

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt(System.UInt32) and SetAt(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue) methods.

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

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

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

    Parameters

    Returns

    Remarks

    The elements are copied to the array in the same order in which the enumerator iterates through the collection. It's typical to specify startIndex as 0 if all you're doing is making a simple copy of the collection items, where you've created a destination array with a length that matches the Size of the collection you're copying.

    This method will throw an exception if the number of elements in the source collection is greater than the length of the destination array specified in items.

    If you are programming using Visual C++ component extensions (C++/CX) or JavaScript, CopyTo has similar behavior to GetMany(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue[]), but note that the parameters are in a different order. Or you can make an IVectorView<T> copy by calling the GetView() method.

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

    Returns an immutable view of the HttpChallengeHeaderValueCollection.

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

    Returns

    Remarks

    When programming with .NET, this method is hidden.

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

    Retrieves the index of an HttpChallengeHeaderValue in the collection.

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

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Indicates whether the item is found.

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

    Remarks

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is IndexOf(Windows.Web.Http.Headers.HttpChallengeHeaderValue,System.UInt32).

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

    Inserts an HttpChallengeHeaderValue into the collection at the specified index.

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

    Parameters

    Remarks

    To add an item to the end position in the collection, you can use the Append(Windows.Web.Http.Headers.HttpChallengeHeaderValue) method. Calling InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue) with an index value that is the same as the Size value is equivalent to calling Append(Windows.Web.Http.Headers.HttpChallengeHeaderValue).

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is InsertAt(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue).

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

    Parses and adds an entry to the HttpChallengeHeaderValueCollection.

    public void ParseAdd(System.String)public void ParseAdd(System.String)Public Function ParseAdd(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 HttpChallengeHeaderValueCollection.

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

    Parameters

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

      The index of the entry to remove.

    Remarks

    If successful, calling this method reduces the collection size by one. Items with index values greater than the called index have their index values reduced by one.

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is RemoveAt(System.UInt32). The behavior of each language's RemoveAt(System.UInt32) is basically the same.

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

    Removes the last HttpChallengeHeaderValue item from the collection.

    public void RemoveAtEnd()public void RemoveAtEnd()Public Function RemoveAtEnd() As void

    Remarks

    When programming with .NET, this method is hidden and developers should use RemoveAt(System.UInt32).

  • ReplaceAll(Windows.Web.Http.Headers.HttpChallengeHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpChallengeHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpChallengeHeaderValue[])
    ReplaceAll(Windows.Web.Http.Headers.HttpChallengeHeaderValue[])

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

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

    Parameters

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

      The collection of HttpChallengeHeaderValue items to add to the collection.

    Remarks

    When programming with .NET, this method is hidden.

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

    Sets the HttpChallengeHeaderValue at the specified index in the collection.

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

    Parameters

    Remarks

    If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt(System.UInt32) and SetAt(System.UInt32,Windows.Web.Http.Headers.HttpChallengeHeaderValue) methods.

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

    Returns a string that represents the current HttpChallengeHeaderValueCollection 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 HttpChallengeHeaderValueCollection.

    public bool TryParseAdd(System.String)public bool TryParseAdd(System.String)Public Function TryParseAdd(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.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Web.Http.Headers.dll