Http​Challenge​Header​Value​Collection Http​Challenge​Header​Value​Collection Http​Challenge​Header​Value​Collection Class

Definition

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

public : sealed class HttpChallengeHeaderValueCollection : IIterable, IVector, IStringable, IHttpChallengeHeaderValueCollectionpublic sealed class HttpChallengeHeaderValueCollection : IEnumerable, IList, IStringable, IHttpChallengeHeaderValueCollectionPublic NotInheritable Class HttpChallengeHeaderValueCollection Implements IEnumerable, IList, IStringable, IHttpChallengeHeaderValueCollection
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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

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.

Properties

Item[Int32] Item[Int32] Item[Int32]

Gets or sets the element at the specified index.

This member is not implemented in C++T this[int index] { get; set; }Property Item(index As Integer) As T
Parameters
index

The zero-based index of the element to get or set.

Value
T T T

The element at the specified index.

Attributes
Exceptions

index is not a valid index in the System.Collections.Generic.IList`1.

The property is set and the System.Collections.Generic.IList`1 is read-only.

Size Size Size

Gets the number of HttpChallengeHeaderValue objects in the collection.

public : unsigned short Size { get; }This member is not implemented in C#This member is not implemented in VB.Net
Value
unsigned short uint uint

The number of HttpChallengeHeaderValue objects in the HttpChallengeHeaderValueCollection.

Attributes

Remarks

The Size value returns the true number of items. API that use the index, such as IndexOf, use a zero-based index, so you would subtract one from Size in order to specify that you want the last item in the collection.

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

Methods

Append(HttpChallengeHeaderValue) Append(HttpChallengeHeaderValue) Append(HttpChallengeHeaderValue)

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

public : void Append(HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
Attributes

Remarks

After you've added an item, you can use the IndexOf 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 method.

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

See Also

Clear() Clear() Clear()

Removes all HttpChallengeHeaderValue objects from the collection.

public : void Clear()This member is not implemented in C#This member is not implemented in VB.Net
Attributes
See Also

First() First() First()

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

public : IIterator<HttpChallengeHeaderValue> First()This member is not implemented in C#This member is not implemented in VB.Net
Returns
Attributes
See Also

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

Returns the HttpChallengeHeaderValue at the specified index in the collection.

public : HttpChallengeHeaderValue GetAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

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

Returns
Attributes

Remarks

If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt and SetAt methods.

See Also

GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the collection.

This member is not implemented in C++IEnumerator<T> GetEnumerator()Function GetEnumerator As IEnumerator(Of T)
Returns

An enumerator that can be used to iterate through the collection.

Attributes

GetMany(UInt32, HttpChallengeHeaderValue[]) GetMany(UInt32, HttpChallengeHeaderValue[]) GetMany(UInt32, HttpChallengeHeaderValue[])

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

public : unsigned short GetMany(unsigned int startIndex, HttpChallengeHeaderValue[] items)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
startIndex
unsigned int UInt32 UInt32

The zero-based index of the start of the HttpChallengeHeaderValue items in the HttpChallengeHeaderValueCollection.

items
HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[]

An array of HttpChallengeHeaderValue items that start at startIndex in the HttpChallengeHeaderValueCollection.

Returns
unsigned short uint uint

The number of HttpChallengeHeaderValue items retrieved.

Attributes

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, but note that the parameters are in a different order. Or you can make an IVectorView copy by calling the GetView method.

See Also

GetView() GetView() GetView()

Returns an immutable view of the HttpChallengeHeaderValueCollection.

public : IVectorView<HttpChallengeHeaderValue> GetView()This member is not implemented in C#This member is not implemented in VB.Net
Returns
IVectorView<HttpChallengeHeaderValue> IReadOnlyList<HttpChallengeHeaderValue> IReadOnlyList<HttpChallengeHeaderValue>

The view of the HttpChallengeHeaderValueCollection.

Attributes

Remarks

When programming with .NET, this method is hidden.

IndexOf(T) IndexOf(T) IndexOf(T)

Determines the index of a specific item in the System.Collections.Generic.IList`1.

This member is not implemented in C++int IndexOf(T item)Function IndexOf(item As T) As Integer
Parameters
item
T T T

The object to locate in the System.Collections.Generic.IList`1.

Returns

The index of item if found in the list; otherwise, -1.

Attributes

IndexOf(HttpChallengeHeaderValue, UInt32) IndexOf(HttpChallengeHeaderValue, UInt32) IndexOf(HttpChallengeHeaderValue, UInt32)

Retrieves the index of an HttpChallengeHeaderValue in the collection.

public : PlatForm::Boolean IndexOf(HttpChallengeHeaderValue value, unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The index of the HttpChallengeHeaderValue in the HttpChallengeHeaderValueCollection.

If the item is found, this is the zero-based index of the item; otherwise, this parameter is 0.

Returns
PlatForm::Boolean bool bool

Indicates whether the item is found.

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

Attributes

Remarks

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

See Also

Insert(Int32, T) Insert(Int32, T) Insert(Int32, T)

Inserts an item to the System.Collections.Generic.IList`1 at the specified index.

This member is not implemented in C++void Insert(int index, T item)Sub Insert(index As Integer, item As T)
Parameters
index

The zero-based index at which item should be inserted.

item
T T T

The object to insert into the System.Collections.Generic.IList`1.

Attributes
Exceptions

index is not a valid index in the System.Collections.Generic.IList`1.

The System.Collections.Generic.IList`1 is read-only.

InsertAt(UInt32, HttpChallengeHeaderValue) InsertAt(UInt32, HttpChallengeHeaderValue) InsertAt(UInt32, HttpChallengeHeaderValue)

Inserts an HttpChallengeHeaderValue into the collection at the specified index.

public : void InsertAt(unsigned int index, HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The zero-based index at which value should be inserted.

value
HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue

The object to insert into the collection.

Attributes

Remarks

To add an item to the end position in the collection, you can use the Append method. Calling InsertAt with an index value that is the same as the Size value is equivalent to calling Append.

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

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

Parses and adds an entry to the HttpChallengeHeaderValueCollection.

public : void ParseAdd(PlatForm::String input)public void ParseAdd(String input)Public Function ParseAdd(input As String) As void
Parameters
input
PlatForm::String String String

The entry to add.

Attributes

Remarks

Below are exceptions that this function throws.

E_INVALIDARG

The input parameter is null (Nothing in Visual Basic).

The input parameter is not a valid value for the Proxy-Authenticate or WWW-Authenticate HTTP header.

See Also

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the System.Collections.Generic.IList`1 item at the specified index.

This member is not implemented in C++void RemoveAt(int index)Sub RemoveAt(index As Integer)
Parameters
index

The zero-based index of the item to remove.

Attributes
Exceptions

index is not a valid index in the System.Collections.Generic.IList`1.

The System.Collections.Generic.IList`1 is read-only.

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

Removes the entry at the specified index from the HttpChallengeHeaderValueCollection.

public : void RemoveAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The index of the entry to remove.

Attributes

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. The behavior of each language's RemoveAt is basically the same.

See Also

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last HttpChallengeHeaderValue item from the collection.

public : void RemoveAtEnd()This member is not implemented in C#This member is not implemented in VB.Net
Attributes

Remarks

When programming with .NET, this method is hidden and developers should use Remove.

ReplaceAll(HttpChallengeHeaderValue[]) ReplaceAll(HttpChallengeHeaderValue[]) ReplaceAll(HttpChallengeHeaderValue[])

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

public : void ReplaceAll(HttpChallengeHeaderValue[] items)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
items
HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[]

The collection of HttpChallengeHeaderValue items to add to the collection.

Attributes

Remarks

When programming with .NET, this method is hidden.

SetAt(UInt32, HttpChallengeHeaderValue) SetAt(UInt32, HttpChallengeHeaderValue) SetAt(UInt32, HttpChallengeHeaderValue)

Sets the HttpChallengeHeaderValue at the specified index in the collection.

public : void SetAt(unsigned int index, HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
index
unsigned int UInt32 UInt32

The zero-based index at which to set the HttpChallengeHeaderValue.

Attributes

Remarks

If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt and SetAt methods.

ToString() ToString() ToString()

Returns a string that represents the current HttpChallengeHeaderValueCollection object.

public : PlatForm::String ToString()public string ToString()Public Function ToString() As string
Returns
PlatForm::String string string

A string that represents the current object.

Attributes

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

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

public : PlatForm::Boolean TryParseAdd(PlatForm::String input)public bool TryParseAdd(String input)Public Function TryParseAdd(input As String) As bool
Parameters
input
PlatForm::String String String

The item to parse and add.

Returns
PlatForm::Boolean bool bool

true if the item successfully parsed and was added; otherwise false.

Attributes

See Also