Megosztás a következőn keresztül:


HttpResponseHeaderCollection.ProxyAuthenticate Property

Definition

Gets the HttpChallengeHeaderValueCollection of HttpChallengeHeaderValue objects that represent the value of a Proxy-Authenticate HTTP header on an HTTP response.

public:
 property HttpChallengeHeaderValueCollection ^ ProxyAuthenticate { HttpChallengeHeaderValueCollection ^ get(); };
HttpChallengeHeaderValueCollection ProxyAuthenticate();
public HttpChallengeHeaderValueCollection ProxyAuthenticate { get; }
var httpChallengeHeaderValueCollection = httpResponseHeaderCollection.proxyAuthenticate;
Public ReadOnly Property ProxyAuthenticate As HttpChallengeHeaderValueCollection

Property Value

The collection of HttpChallengeHeaderValue objects that represent the value of a Proxy-Authenticate HTTP header on an HTTP response. An empty collection means that the header is absent.

Remarks

The following sample code shows a method to get and set the Proxy-Authenticate header on an HttpResponseMessage object using the ProxyAuthenticate property on the HttpResponseHeaderCollection object.

// Proxy-Authenticate: Basic
// HttpChallengeHeaderValueCollection
// HttpChallengeHeaderValue has Scheme and Token (both strings) + Parameters
// Parameters is an IList<HttpNameValueHeaderValue>
// HttpNameValueHeaderValue has Name and Value, both strings
    void DemoProxyAuthenticate(HttpResponseMessage response) {
        var h = response.Headers;
        h.ProxyAuthenticate.TryParseAdd("Basic");
        h.ProxyAuthenticate.Add(new HttpChallengeHeaderValue("digest", "token"));

        var header = h.ProxyAuthenticate;
        uiLog.Text += "\nPROXY AUTHENTICATE HEADER\n";
        foreach (var item in header) {
            // Parameters is an IList<HttpNameValueHeaderValue> of Name/Value strings
            var parameterString = "";
            foreach (var parameter in item.Parameters) {
                parameterString += string.Format("[{0}={1}] ", parameter.Name, parameter.Value);
            }
            if (parameterString == "") {
                parameterString = "(no parameters)";
            }
            uiLog.Text += string.Format("Scheme: {0} Token: {1} Parameters: {2} ToString(): {3}\n", item.Scheme, item.Token, parameterString, item.ToString());
        }
        uiLog.Text += String.Format("ProxyAuthenticate: {0}\n", header.ToString());
    }

Applies to

See also