共用方式為


HttpContentHeaderCollection.ContentEncoding 屬性

定義

取得 HttpContentCodingHeaderValueCollectionHttpContentCodingHeaderValue 物件,這些物件代表 HTTP 內容上 HTTP Content-Encoding 標頭的值。

public:
 property HttpContentCodingHeaderValueCollection ^ ContentEncoding { HttpContentCodingHeaderValueCollection ^ get(); };
HttpContentCodingHeaderValueCollection ContentEncoding();
public HttpContentCodingHeaderValueCollection ContentEncoding { get; }
var httpContentCodingHeaderValueCollection = httpContentHeaderCollection.contentEncoding;
Public ReadOnly Property ContentEncoding As HttpContentCodingHeaderValueCollection

屬性值

HttpContentCodingHeaderValue物件的集合,這些物件代表 HTTP 內容上 HTTP Content-Encoding標頭的值。 空集合表示標頭不存在。

備註

下列範例程式碼示範使用HttpContentHeaderCollection物件上的 ContentEncoding 屬性,取得或設定 HTTP 內容上Content-Encoding標頭值的方法。

// Content-Encoding header
// HttpContentCodingHeaderValueCollection
// HttpContentCodingHeaderValue [has ContentCoding, a string]
void DemoContentEncoding(IHttpContent content) {
    var h = content.Headers;

    h.ContentEncoding.TryParseAdd("gzip");
    h.ContentEncoding.TryParseAdd("cab, compress");
    h.ContentEncoding.Add(new HttpContentCodingHeaderValue("myencoding"));

    var header = h.ContentEncoding;
    uiLog.Text += "\nCONTENT ENCODING HEADER\n";
    foreach (var item in header) {
        uiLog.Text += string.Format("ContentCoding: {0}  ToString: {1}\n", item.ContentCoding, item.ToString());
    }
    uiLog.Text += string.Format("ContentEncoding: ToString: {0}\n\n", header.ToString());
}

適用於

另請參閱