HttpContentHeaderCollection
HttpContentHeaderCollection
HttpContentHeaderCollection
HttpContentHeaderCollection
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// You can use this class in JavaScript.
- Attributes
| 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
Constructors
HttpContentHeaderCollection() HttpContentHeaderCollection() HttpContentHeaderCollection() HttpContentHeaderCollection()
Initializes a new instance of the HttpContentHeaderCollection class.
public : HttpContentHeaderCollection()public HttpContentHeaderCollection()Public Sub New()// You can use this method in JavaScript.
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 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// You can use this property in JavaScript.
- Value
- HttpContentDispositionHeaderValue 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.
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 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// You can use this property in JavaScript.
- Value
- HttpContentCodingHeaderValueCollection 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.
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 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// You can use this property in JavaScript.
- Value
- HttpLanguageHeaderValueCollection 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
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 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>// You can use this property in JavaScript.
- Value
- IReference<ulong> Nullable<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.
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 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// You can use this property in JavaScript.
- Value
- Uri Uri Uri Uri
The value of the HTTP Content-Location header on the HTTP content. A null value means that the header is absent.
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
-
ContentMD5 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// You can use this property in JavaScript.
The value of the HTTP Content-MD5 header on the HTTP content. A null value means that the header is absent.
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 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// You can use this property in JavaScript.
- Value
- HttpContentRangeHeaderValue 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.
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 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// You can use this property in JavaScript.
- Value
- HttpMediaTypeHeaderValue 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.
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 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>// You can use this property in JavaScript.
- Value
- IReference<DateTime> Nullable<DateTimeOffset> 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.
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] 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 TValueTValue this[TKey key] { get; set; }
- key
- TKey TKey TKey TKey
The key of the element to get or set.
- Value
- TValue TValue TValue TValue
The element with the specified key.
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 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)ICollection<TKey> Keys { get; }
- Value
An System.Collections.Generic.ICollection`1 containing the keys of the object that implements System.Collections.Generic.IDictionary`2.
LastModified 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>// You can use this property in JavaScript.
- Value
- IReference<DateTime> Nullable<DateTimeOffset> 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.
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 Size
Gets the number of objects in the HttpContentHeaderCollection.
public : unsigned int Size { get; }This member is not implemented in C#This member is not implemented in VB.Net// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The number of objects in the HttpContentHeaderCollection.
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 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)ICollection<TValue> Values { get; }
- Value
An System.Collections.Generic.ICollection`1 containing the values in the object that implements System.Collections.Generic.IDictionary`2.
Methods
Add(TKey, TValue) 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)void Add(TKey key, TValue value)
- key
- TKey TKey TKey TKey
The object to use as the key of the element to add.
- value
- TValue TValue TValue TValue
The object to use as the value of the element to add.
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) 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// You can use this method in JavaScript.
- name
- PlatForm::String String String String
The name of the value to add.
- value
- PlatForm::String String String String
The item value to add.
Clear() 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// You can use this method in JavaScript.
ContainsKey(TKey) 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 Booleanbool ContainsKey(TKey key)
- key
- TKey TKey TKey TKey
The key to locate in the System.Collections.Generic.IDictionary`2.
true if the System.Collections.Generic.IDictionary`2 contains an element with the key; otherwise, false.
key is null.
First() 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// You can use this method in JavaScript.
An object that can be used to enumerate the items in the collection. The iterator points to the first item in the HttpContentHeaderCollection.
GetEnumerator() 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)IEnumerator<T> GetEnumerator()
An enumerator that can be used to iterate through the collection.
GetView() 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// You can use this method in JavaScript.
The view of the HttpContentHeaderCollection.
Remarks
When programming with .NET, this method is hidden.
HasKey(String) 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// You can use this method in JavaScript.
- key
- PlatForm::String String String String
The key associated with the item to locate.
true if the key is found; otherwise, false.
Remarks
When programming with .NET, this method is hidden and developers should use ContainsKey.
Insert(String, String) 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// You can use this method in JavaScript.
- key
- PlatForm::String String String String
The key of the item to be inserted.
- value
- PlatForm::String String String String
The value of the item to insert.
true if an item with the specified key is an existing item that was replaced; otherwise false.
Remarks
When programming with .NET, this method is hidden and developers should use the Add methods.
Lookup(String) 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// You can use this method in JavaScript.
- key
- PlatForm::String String String String
The key of the item to lookup.
The value, if an item with the specified key exists. Use the HasKey method to determine whether the key exists.
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) 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 Booleanbool Remove(TKey key)
- key
- TKey TKey TKey TKey
The key of the element to remove.
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.
key is null.
The System.Collections.Generic.IDictionary`2 is read-only.
Remove(String) 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// You can use this method in JavaScript.
- key
- PlatForm::String String String String
The key of the item to remove.
ToString() ToString() ToString() ToString()
Returns a string that represents the current HttpContentHeaderCollection object.
public : PlatForm::String ToString()public string ToString()Public Function ToString() As string// You can use this method in JavaScript.
A string that represents the current object.
TryAppendWithoutValidation(String, String) 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// You can use this method in JavaScript.
- name
- PlatForm::String String String String
The name of the item to append.
- value
- PlatForm::String String String String
The value of the item to append.
true if the item was appended; otherwise false.
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) 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 Booleanbool TryGetValue(TKey key, out TValue value)
- key
- TKey TKey TKey TKey
The key whose value to get.
- value
- TValue 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.
true if the object that implements System.Collections.Generic.IDictionary`2 contains an element with the specified key; otherwise, false.
key is null.