Http​Content​Header​Collection Http​Content​Header​Collection Http​Content​Header​Collection Class

Definition

Provides a collection of the HTTP headers associated with content on an HTTP request or response.

public : sealed class HttpContentHeaderCollection : IIterable, IMap, IStringable, IHttpContentHeaderCollectionpublic sealed class HttpContentHeaderCollection : IEnumerable, IDictionary, IStringable, IHttpContentHeaderCollectionPublic NotInheritable Class HttpContentHeaderCollection Implements IEnumerable, IDictionary, IStringable, IHttpContentHeaderCollection
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 headers on HTTP content using the properties on the HttpContentHeaderCollection object. The Windows.Web.Http.Headers namespace has a number of strongly-typed header collection and value classes for specific HTTP headers that can be used to get and set headers with validation.


using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateContentHeader()
        {
            DemonstrateHeaderContentContentDisposition(); 
        }

        public void DemonstrateHeaderContentContentDisposition()
        {
            var content = new HttpStringContent("");
            bool parsedOk = false;

            // Set the header with a string.
            HttpContentDispositionHeaderValue value;
            parsedOk = HttpContentDispositionHeaderValue.TryParse("attachment; filename=\"fname.ext\"", out value);
            content.Headers.ContentDisposition = value;

            // Set the header with a strong type.

            content.Headers.ContentDisposition = new HttpContentDispositionHeaderValue("attachment");
            content.Headers.ContentDisposition.FileName = "myfile.exe";


            // Get the strong type out
            System.Diagnostics.Debug.WriteLine("ContentDisposition filename: {0}={1}", 
                content.Headers.ContentDisposition.DispositionType,
                content.Headers.ContentDisposition.FileName);

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The ContentDisposition ToString() results: {0}", content.Headers.ContentDisposition.ToString());
        }

Remarks

The HttpContentHeaderCollection is a collection of the HTTP headers associated with the HTTP content on an HTTP request or an HTTP response message. The HttpContentHeaderCollection object can be used to get or set the specific headers on the HTTP content. Most of the properties on the HttpContentHeaderCollection object provide access to a container collection for a specific HTTP header.

The HttpContentHeaderCollection has a constructor and also is returned by the property on HttpBufferContent, HttpFormUrlEncodedContent, HttpMultipartContent, HttpMultipartFormDataContent, HttpStreamContent, and HttpStringContent, classes and the IHttpContent interface.

Enumerating the collection in C# or Microsoft Visual Basic

You can iterate through an HttpContentHeaderCollection 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 explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast the collection object to IEnumerable<T> with a KeyValuePair of String and String as the constraint.

Constructors

HttpContentHeaderCollection() HttpContentHeaderCollection() HttpContentHeaderCollection()

Initializes a new instance of the HttpContentHeaderCollection class.

public : HttpContentHeaderCollection()public HttpContentHeaderCollection()Public Sub New()
Attributes

Remarks

An HttpContentHeaderCollection object is returned by the property on HttpBufferContent, HttpFormUrlEncodedContent, HttpMultipartContent, HttpMultipartFormDataContent, HttpStreamContent, and HttpStringContent, classes and the IHttpContent interface.

Properties

ContentDisposition ContentDisposition ContentDisposition

Gets or sets the HttpContentDispositionHeaderValue object that represents the value of an HTTP Content-Disposition header on the HTTP content.

public : HttpContentDispositionHeaderValue ContentDisposition { get; set; }public HttpContentDispositionHeaderValue ContentDisposition { get; set; }Public ReadWrite Property ContentDisposition As HttpContentDispositionHeaderValue
Value
HttpContentDispositionHeaderValue HttpContentDispositionHeaderValue HttpContentDispositionHeaderValue

The object that represent the value of HTTP Content-Disposition header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-Disposition header value on HTTP content using the ContentDisposition property on the HttpContentHeaderCollection object.

    // Content-Disposition header
    // HttpContentDispositionHeaderValue
    void DemoContentDisposition(IHttpContent content) {
        var h = content.Headers;

        HttpContentDispositionHeaderValue value;
        bool ok = HttpContentDispositionHeaderValue.TryParse("attachment; filename=\"myfile.txt\"; myparam=myvalue", out value);
        h.ContentDisposition = value;

        h.ContentDisposition = HttpContentDispositionHeaderValue.Parse("attachment; filename=\"myfile.txt\"; myparam=myvalue");
        var header = h.ContentDisposition;

        uiLog.Text += "\nCONTENT DISPOSITION HEADER\n";
        // Content-Disposition: attachment; filename="fname.ext"

        // ContentDisposition is a HttpContentDispositionHeaderValue and contains:
        // DispositionType, FileName, FileNameStar, Name: all strings
        // Size: nullable long
        // Parameters: IList<HttpNameValueHeaderValue> 
        var parameterString = "";
        foreach (var parameter in header.Parameters) {
            parameterString += string.Format("[{0}={1}] ", parameter.Name, parameter.Value);
        }
        if (parameterString == "") {
            parameterString = "(no parameters)";
        }

        uiLog.Text += string.Format("ContentDisposition: DispositionType: {0} FileName: {1} FileNameStar: {2} Name: {3} Parameters: {4} Size: {5} ToString: {6}\n\n", 
        header.DispositionType, header.FileName, header.FileNameStar, header.Name, parameterString, header.Size, header.ToString());
    }
See Also

ContentEncoding ContentEncoding ContentEncoding

Gets the HttpContentCodingHeaderValueCollection of HttpContentCodingHeaderValue objects that represent the value of an HTTP Content-Encoding header on the HTTP content.

public : HttpContentCodingHeaderValueCollection ContentEncoding { get; }public HttpContentCodingHeaderValueCollection ContentEncoding { get; }Public ReadOnly Property ContentEncoding As HttpContentCodingHeaderValueCollection
Value
HttpContentCodingHeaderValueCollection HttpContentCodingHeaderValueCollection HttpContentCodingHeaderValueCollection

The collection of HttpContentCodingHeaderValue objects that represent the value of an HTTP Content-Encoding header on the HTTP content. An empty collection means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-Encoding header value on HTTP content using the ContentEncoding property on the HttpContentHeaderCollection object.

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

ContentLanguage ContentLanguage ContentLanguage

Gets the HttpLanguageHeaderValueCollection of objects that represent the value of an HTTP Content-Language header on the HTTP content.

public : HttpLanguageHeaderValueCollection ContentLanguage { get; }public HttpLanguageHeaderValueCollection ContentLanguage { get; }Public ReadOnly Property ContentLanguage As HttpLanguageHeaderValueCollection
Value
HttpLanguageHeaderValueCollection HttpLanguageHeaderValueCollection HttpLanguageHeaderValueCollection

The collection of objects that represent the value of an HTTP Content-Language header on the HTTP content. An empty collection means that the header is absent

Attributes

Remarks

The following sample code shows a method to get or set the Content-Language header value on HTTP content using the ContentLanguage property on the HttpContentHeaderCollection object.

    // Content-Language header
    // HttpLanguageHeaderValueCollection (of Windows.Globalization.Language)
    void DemoContentLanguage(IHttpContent content) {
        var h = content.Headers;

        h.ContentLanguage.TryParseAdd("en-us");
        h.ContentLanguage.TryParseAdd("ru-ru, ru-us");
        h.ContentLanguage.Add(new Windows.Globalization.Language("ko-ko"));

        var header = h.ContentLanguage;
        uiLog.Text += "\nCONTENT LANGUAGE HEADER\n";
        foreach (var item in header) {
            uiLog.Text += string.Format("DisplayName: {0} ToString: {1}\n", item.DisplayName, item.ToString());
        }
        uiLog.Text += string.Format("ContentLanguage: ToString: {0}\n\n", header.ToString());
    }
See Also

ContentLength ContentLength ContentLength

Gets or sets the value of the HTTP Content-Length header on the HTTP content.

public : IReference<ulong> ContentLength { get; set; }public Nullable<ulong> ContentLength { get; set; }Public ReadWrite Property ContentLength As Nullable<ulong>
Value
IReference<ulong> Nullable<ulong> Nullable<ulong>

The value of the HTTP Content-Length header value on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-Length header on HTTP content using the ContentLength property on the HttpContentHeaderCollection object.

    // Content-Length header
    // nullable ulong
    void DemoContentLength(IHttpContent content) {
        var h = content.Headers;

        h.ContentLength = 313;

        var header = h.ContentLength;
        uiLog.Text += "\nCONTENT LENGTH HEADER\n";

        uiLog.Text += string.Format("ContentLength: ToString: {0}\n\n", header.ToString());
    }

ContentLocation ContentLocation ContentLocation

Gets or sets the value of the HTTP Content-Location header on the HTTP content.

public : Uri ContentLocation { get; set; }public Uri ContentLocation { get; set; }Public ReadWrite Property ContentLocation As Uri
Value
Uri Uri Uri

The value of the HTTP Content-Location header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-Location header value on HTTP content using the ContentLocation property on the HttpContentHeaderCollection object.

    // Content-Location header
    // Uri
    void DemoContentLocation(IHttpContent content) {
        var h = content.Headers;

        h.ContentLocation = new Uri("http://example.com/");

        var header = h.ContentLocation;
        uiLog.Text += "\nCONTENT LOCATION HEADER\n";

        uiLog.Text += string.Format("ContentLocation: ToString: {0}\n\n", header.ToString());
    }
See Also
UriUriUri

ContentMD5 ContentMD5 ContentMD5

Gets or sets the value of an HTTP Content-MD5 header on the HTTP content.

public : IBuffer ContentMD5 { get; set; }public IBuffer ContentMD5 { get; set; }Public ReadWrite Property ContentMD5 As IBuffer
Value
IBuffer IBuffer IBuffer

The value of the HTTP Content-MD5 header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-MD5 header value on HTTP content using the ContentMD5 property on the HttpContentHeaderCollection object.

    // Content-MD5 header
    // IBuffer
    void DemoContentMD5(IHttpContent content) {
        var h = content.Headers;

        var str = "This is my content string";
        var alg = Windows.Security.Cryptography.Core.HashAlgorithmProvider.OpenAlgorithm("MD5");
        var buff = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(str, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);
        var hashed = alg.HashData(buff);
        var res = Windows.Security.Cryptography.CryptographicBuffer.EncodeToHexString(hashed);
        h.ContentMD5 = hashed;

        var header = h.ContentMD5;
        uiLog.Text += "\nCONTENT MD5 HEADER\n";

        uiLog.Text += string.Format("ContentMD5: ToString: {0}\n\n", header.ToString());
        uiLog.Text += string.Format("ContentMD5: base64: {0} hex: {1}\n\n", Convert.ToBase64String(h.ContentMD5.ToArray()), res);
    }

ContentRange ContentRange ContentRange

Gets or sets the HttpContentRangeHeaderValue object that represent the value of an HTTP Content-Range header on the HTTP content.

public : HttpContentRangeHeaderValue ContentRange { get; set; }public HttpContentRangeHeaderValue ContentRange { get; set; }Public ReadWrite Property ContentRange As HttpContentRangeHeaderValue
Value
HttpContentRangeHeaderValue HttpContentRangeHeaderValue HttpContentRangeHeaderValue

The object that represent the value of the HTTP Content-Range header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The following sample code shows a method to get or set the Content-Range header value on HTTP content using the ContentRange property on the HttpContentHeaderCollection object.

    // Content-Range header
    // HttpContentRangeHeaderValue (Unit=string, FirstBytePosition, LastBytePosition, Length) all nullable ulong
    //
    void DemoContentRange(IHttpContent content) {
        var h = content.Headers;
        h.ContentRange = new HttpContentRangeHeaderValue (10, 20, 333);

        var header = h.ContentRange;
        uiLog.Text += "\nCONTENT RANGE HEADER\n";

        uiLog.Text += string.Format("ContentRange: Unit: {0} FirstBytePosition: {1} LastBytePosition: {2} Length: {3} ToString: {4}\n\n", header.Unit, header.FirstBytePosition, header.LastBytePosition, header.Length, header.ToString());
    }
See Also

ContentType ContentType ContentType

Gets or sets the HttpMediaTypeHeaderValue object that represent the value of an HTTP Content-Type header on the HTTP content.

public : HttpMediaTypeHeaderValue ContentType { get; set; }public HttpMediaTypeHeaderValue ContentType { get; set; }Public ReadWrite Property ContentType As HttpMediaTypeHeaderValue
Value
HttpMediaTypeHeaderValue HttpMediaTypeHeaderValue HttpMediaTypeHeaderValue

The object that represent the value of an HTTP Content-Type header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The ContentType property represents the Content-Type header value on HTTP content. The Content-Type header is the MIME type of the content.

The following sample code shows a method to get or set the Content-Type header value on HTTP content using the ContentType property on the HttpContentHeaderCollection object.

    // Content-Type header
    // HttpMediaTypeHeaderValue (MediaType, Charset are strings, Parameters is an IList<HttpNameValueHeaderValue>)
    //
    void DemoContentType(IHttpContent content) {
        var h = content.Headers;
        h.ContentType = new HttpMediaTypeHeaderValue("myMediaType");

        var header = h.ContentType;
        uiLog.Text += "\nCONTENT TYPE HEADER\n";

        // Parameters is an IList<HttpNameValueHeaderValue> of Name/Value strings
        var parameterString = "";
        foreach (var parameter in header.Parameters) {
                parameterString += string.Format("[{0}={1}] ", parameter.Name, parameter.Value);
        }
        if (parameterString == "") {
                parameterString = "(no parameters)";
        }

        uiLog.Text += string.Format("Content-Type: MediaType: {0} CharSet: {1} Parameters: {2} ToString: {3}\n", header.MediaType, header.CharSet, parameterString, header.ToString());
    }
See Also

Expires Expires Expires

Gets or sets the DateTime object that represents the value of an HTTP Expires header on the HTTP content.

public : IReference<DateTime> Expires { get; set; }public Nullable<DateTimeOffset> Expires { get; set; }Public ReadWrite Property Expires As Nullable<DateTimeOffset>
Value
IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset>

The object that represents the value of an HTTP Expires header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The Expires property represents the value of the Expires header on HTTP content. The Expires header is the date and time after which the HTTP content is considered outdated.

Javascript and .NET languages do not use the DateTime object directly. In Javascript a DateTime is projected as a object, and in .NET it is projected as a System.DateTimeOffset. Each language transparently handles the conversion to the granularity and date ranges for the respective language.

In C++, a value has the same granularity as a and supports the date ranges required by Javascript and .NET.

For more detailed information, see the Windows.Foundation.DateTime structure.

The following sample code shows a method to get or set the Expires header value on HTTP content using the Expires property on the HttpContentHeaderCollection object.

    // Expires header
    // nullable DateTimeOffset
    //
    void DemoExpires(IHttpContent content) {
        var h = content.Headers;
        h.Expires = DateTimeOffset.Now;

        var header = h.Expires;
        uiLog.Text += "\nEXPIRES HEADER\n";
        uiLog.Text += String.Format ("Expires: {0}\n", header.ToString());
    }

Item[TKey] Item[TKey] Item[TKey]

Gets or sets the element with the specified key.

This member is not implemented in C++TValue this[TKey key] { get; set; }Property Item(key As TKey) As TValue
Parameters
key
TKey TKey TKey

The key of the element to get or set.

Value
TValue TValue TValue

The element with the specified key.

Attributes
Exceptions

key is null.

The property is retrieved and key is not found.

The property is set and the System.Collections.Generic.IDictionary`2 is read-only.

Keys Keys Keys

Gets an System.Collections.Generic.ICollection`1 containing the keys of the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++ICollection<TKey> Keys { get; }ReadOnly Property Keys As ICollection(Of TKey)
Value

An System.Collections.Generic.ICollection`1 containing the keys of the object that implements System.Collections.Generic.IDictionary`2.

Attributes

LastModified LastModified LastModified

Gets or sets the DateTime object that represents the value of an HTTP Last-Modified header on the HTTP content.

public : IReference<DateTime> LastModified { get; set; }public Nullable<DateTimeOffset> LastModified { get; set; }Public ReadWrite Property LastModified As Nullable<DateTimeOffset>
Value
IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset>

The object that represents the value of an HTTP Last-Modified header on the HTTP content. A null value means that the header is absent.

Attributes

Remarks

The LastModified property represents the Last-Modified header on HTTP content. The Last-Modified header is the date and time that the HTTP content was last modified.

Javascript and .NET languages do not use the DateTime object directly. In Javascript a DateTime is projected as a object, and in .NET it is projected as a System.DateTimeOffset. Each language transparently handles the conversion to the granularity and date ranges for the respective language.

In C++, a value has the same granularity as a and supports the date ranges required by Javascript and .NET.

For more detailed information, see the Windows.Foundation.DateTime structure.

The following sample code shows a method to get or set the Expires header value on HTTP content using the LastModified property on the HttpContentHeaderCollection object.

    // Last-Modified header
    // nullable DateTimeOffset
    //
    void DemoLastModified(IHttpContent content) {
        var h = content.Headers;
        h.LastModified = DateTimeOffset.Now;

        var header = h.LastModified;
        uiLog.Text += "\nLAST MODIFIED HEADER\n";
        uiLog.Text += String.Format("LastModified: {0}\n", header.ToString());
    }

Size Size Size

Gets the number of objects in the HttpContentHeaderCollection.

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 objects in the HttpContentHeaderCollection.

Attributes

Remarks

The Size property returns the true number of items.

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

Values Values Values

Gets an System.Collections.Generic.ICollection`1 containing the values in the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++ICollection<TValue> Values { get; }ReadOnly Property Values As ICollection(Of TValue)
Value

An System.Collections.Generic.ICollection`1 containing the values in the object that implements System.Collections.Generic.IDictionary`2.

Attributes

Methods

Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue)

Adds an element with the provided key and value to the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++void Add(TKey key, TValue value)Sub Add(key As TKey, value As TValue)
Parameters
key
TKey TKey TKey

The object to use as the key of the element to add.

value
TValue TValue TValue

The object to use as the value of the element to add.

Attributes
Exceptions

key is null.

An element with the same key already exists in the System.Collections.Generic.IDictionary`2.

The System.Collections.Generic.IDictionary`2 is read-only.

Append(String, String) Append(String, String) Append(String, String)

Adds a new item to the end of the HttpContentHeaderCollection.

public : void Append(PlatForm::String name, PlatForm::String value)public void Append(String name, String value)Public Function Append(name As String, value As String) As void
Parameters
name
PlatForm::String String String

The name of the value to add.

value
PlatForm::String String String

The item value to add.

Attributes

Clear() Clear() Clear()

Removes all objects from the HttpContentHeaderCollection.

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

ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey)

Determines whether the System.Collections.Generic.IDictionary`2 contains an element with the specified key.

This member is not implemented in C++bool ContainsKey(TKey key)Function ContainsKey(key As TKey) As Boolean
Parameters
key
TKey TKey TKey

The key to locate in the System.Collections.Generic.IDictionary`2.

Returns

true if the System.Collections.Generic.IDictionary`2 contains an element with the key; otherwise, false.

Attributes
Exceptions

key is null.

First() First() First()

Retrieves an iterator to the first item in the HttpContentHeaderCollection.

public : IIterator<IKeyValuePair<PlatForm::String, PlatForm::String>> First()This member is not implemented in C#This member is not implemented in VB.Net
Returns
IIterator<IKeyValuePair<PlatForm::String, PlatForm::String>> IIterator<KeyValuePair<string, string>> IIterator<KeyValuePair<string, string>>

An object that can be used to enumerate the items in the collection. The iterator points to the first item in the HttpContentHeaderCollection.

Attributes

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

GetView() GetView() GetView()

Returns an immutable view of the HttpContentHeaderCollection.

public : IMapView<PlatForm::String, PlatForm::String> GetView()This member is not implemented in C#This member is not implemented in VB.Net
Returns
IMapView<PlatForm::String, PlatForm::String> IReadOnlyDictionary<string, string> IReadOnlyDictionary<string, string>

The view of the HttpContentHeaderCollection.

Attributes

Remarks

When programming with .NET, this method is hidden.

HasKey(String) HasKey(String) HasKey(String)

Determines whether the HttpContentHeaderCollection contains the specified key.

public : PlatForm::Boolean HasKey(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key associated with the item to locate.

Returns
PlatForm::Boolean bool bool

true if the key is found; otherwise, false.

Attributes

Remarks

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

Insert(String, String) Insert(String, String) Insert(String, String)

Inserts or replaces an item in the HttpContentHeaderCollection with the specified key and value.

public : PlatForm::Boolean Insert(PlatForm::String key, PlatForm::String value)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the item to be inserted.

value
PlatForm::String String String

The value of the item to insert.

Returns
PlatForm::Boolean bool bool

true if an item with the specified key is an existing item that was replaced; otherwise false.

Attributes

Remarks

When programming with .NET, this method is hidden and developers should use the Add methods.

Lookup(String) Lookup(String) Lookup(String)

Finds an item in the HttpContentHeaderCollection if it exists.

public : PlatForm::String Lookup(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the item to lookup.

Returns
PlatForm::String string string

The value, if an item with the specified key exists. Use the HasKey method to determine whether the key exists.

Attributes

Remarks

Use the HasKey method to determine whether the key exists in the HttpContentHeaderCollection.

When programming with .NET, this method is hidden and developers should use the Item indexer.

See Also

Remove(TKey) Remove(TKey) Remove(TKey)

Removes the element with the specified key from the System.Collections.Generic.IDictionary`2.

This member is not implemented in C++bool Remove(TKey key)Function Remove(key As TKey) As Boolean
Parameters
key
TKey TKey TKey

The key of the element to remove.

Returns

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original System.Collections.Generic.IDictionary`2.

Attributes
Exceptions

key is null.

The System.Collections.Generic.IDictionary`2 is read-only.

Remove(String) Remove(String) Remove(String)

Removes a specific object from the HttpContentHeaderCollection.

public : void Remove(PlatForm::String key)This member is not implemented in C#This member is not implemented in VB.Net
Parameters
key
PlatForm::String String String

The key of the item to remove.

Attributes

ToString() ToString() ToString()

Returns a string that represents the current HttpContentHeaderCollection 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

TryAppendWithoutValidation(String, String) TryAppendWithoutValidation(String, String) TryAppendWithoutValidation(String, String)

Try to append the specified item to the HttpContentHeaderCollection without validation.

public : PlatForm::Boolean TryAppendWithoutValidation(PlatForm::String name, PlatForm::String value)public bool TryAppendWithoutValidation(String name, String value)Public Function TryAppendWithoutValidation(name As String, value As String) As bool
Parameters
name
PlatForm::String String String

The name of the item to append.

value
PlatForm::String String String

The value of the item to append.

Returns
PlatForm::Boolean bool bool

true if the item was appended; otherwise false.

Attributes

Remarks

The TryAppendWithoutValidation method is available when you need to work with an HTTP header on HTTP content that doesn't have a strongly-typed class for the HTTP header. If there is a strongly-typed implementation of the HTTP header, then the methods and properties on the strongly-typed class should be used instead of the TryAppendWithoutValidation method.

TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue) TryGetValue(TKey, out TValue)

Gets the value associated with the specified key.

This member is not implemented in C++bool TryGetValue(TKey key, out TValue value)Function TryGetValue(key As TKey, ByRef value As TValue) As Boolean
Parameters
key
TKey TKey TKey

The key whose value to get.

value
TValue TValue TValue

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

true if the object that implements System.Collections.Generic.IDictionary`2 contains an element with the specified key; otherwise, false.

Attributes
Exceptions

key is null.