HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection HttpChallengeHeaderValueCollection Class

Definition

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

public : sealed class HttpChallengeHeaderValueCollection : IStringable
struct winrt::Windows::Web::Http::Headers::HttpChallengeHeaderValueCollection : IStringable
public sealed class HttpChallengeHeaderValueCollection : IStringable
Public NotInheritable Class HttpChallengeHeaderValueCollection Implements IStringable
// This class does not provide a public constructor.
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 with an HttpChallengeHeaderValue constraint.

Properties

Size Size Size Size Size

Gets the number of HttpChallengeHeaderValue objects in the collection.

Methods

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

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

Clear() Clear() Clear() Clear() Clear()

Removes all HttpChallengeHeaderValue objects from the collection.

First() First() First() First() First()

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

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

Returns the HttpChallengeHeaderValue at the specified index in the collection.

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

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

GetView() GetView() GetView() GetView() GetView()

Returns an immutable view of the HttpChallengeHeaderValueCollection.

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

Retrieves the index of an HttpChallengeHeaderValue in the collection.

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

Inserts an HttpChallengeHeaderValue into the collection at the specified index.

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

Parses and adds an entry to the HttpChallengeHeaderValueCollection.

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

Removes the entry at the specified index from the HttpChallengeHeaderValueCollection.

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last HttpChallengeHeaderValue item from the collection.

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

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

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

Sets the HttpChallengeHeaderValue at the specified index in the collection.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpChallengeHeaderValueCollection object.

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

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

See also