HttpResponseHeaderCollection.ProxyAuthenticate 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 HttpChallengeHeaderValueCollection 的 HttpChallengeHeaderValue 物件,這些物件代表 HTTP 回應上 Proxy-Authenticate HTTP 標頭的值。
public:
property HttpChallengeHeaderValueCollection ^ ProxyAuthenticate { HttpChallengeHeaderValueCollection ^ get(); };
HttpChallengeHeaderValueCollection ProxyAuthenticate();
public HttpChallengeHeaderValueCollection ProxyAuthenticate { get; }
var httpChallengeHeaderValueCollection = httpResponseHeaderCollection.proxyAuthenticate;
Public ReadOnly Property ProxyAuthenticate As HttpChallengeHeaderValueCollection
屬性值
HttpChallengeHeaderValue物件的集合,這些物件代表 HTTP 回應上Proxy-Authenticate HTTP 標頭的值。 空集合表示標頭不存在。
備註
下列範例程式碼示範使用HttpResponseHeaderCollection物件上的 ProxyAuthenticate 屬性,取得及設定HttpResponseMessage物件上的Proxy-Authenticate標頭的方法。
// 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());
}