HttpMediaTypeHeaderValue HttpMediaTypeHeaderValue HttpMediaTypeHeaderValue HttpMediaTypeHeaderValue Class

Definition

Represents the value of the Content-Type HTTP header on the HTTP content in a request or a response.

public : sealed class HttpMediaTypeHeaderValue : IStringable, IHttpMediaTypeHeaderValuepublic sealed class HttpMediaTypeHeaderValue : IStringable, IHttpMediaTypeHeaderValuePublic NotInheritable Class HttpMediaTypeHeaderValue Implements IStringable, IHttpMediaTypeHeaderValue// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The HttpMediaTypeHeaderValue class represents the value of the Content-Type HTTP header on HTTP content sent in an HTTP request or received in an HTTP response.

The ContentType property on the HttpContentHeaderCollection returns an HttpMediaTypeHeaderValue object.

Constructors

HttpMediaTypeHeaderValue(String) HttpMediaTypeHeaderValue(String) HttpMediaTypeHeaderValue(String) HttpMediaTypeHeaderValue(String)

Initializes a new instance of the HttpMediaTypeHeaderValue class.

public : HttpMediaTypeHeaderValue(PlatForm::String mediaType)public HttpMediaTypeHeaderValue(String mediaType)Public Sub New(mediaType As String)// You can use this method in JavaScript.
Parameters
mediaType
PlatForm::String String String String

The media-type of the entity-body used in the Content-Type HTTP header.

Properties

CharSet CharSet CharSet CharSet

Gets or sets the character set of the entity-body used in the Content-Type HTTP header.

public : PlatForm::String CharSet { get; set; }public string CharSet { get; set; }Public ReadWrite Property CharSet As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The character set of the entity-body.

Remarks

HTTP uses character set names to indicate or negotiate the character encoding scheme of a textual representation [RFC6365]. A CharSet property is identified by a case-insensitive token.

Character set names ought to be registered in the IANA Character Set registry.

MediaType MediaType MediaType MediaType

Gets or sets the media-type of the entity-body used in the Content-Type HTTP header.

public : PlatForm::String MediaType { get; set; }public string MediaType { get; set; }Public ReadWrite Property MediaType As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The media-type of the entity-body.

Remarks

Internet media types should be registered with IANA. Media type registrations are listed in categories by IANA as MIME Media Types.

Parameters Parameters Parameters Parameters

Gets a set of parameters included in the Content-Type HTTP header.

public : IVector<HttpNameValueHeaderValue> Parameters { get; }public IList<HttpNameValueHeaderValue> Parameters { get; }Public ReadOnly Property Parameters As IList<HttpNameValueHeaderValue>// You can use this property in JavaScript.
Value
IVector<HttpNameValueHeaderValue> IList<HttpNameValueHeaderValue> IList<HttpNameValueHeaderValue> IList<HttpNameValueHeaderValue>

A set of parameters.

Remarks

The Parameters property contains a set of zero or more name/value pairs associated with the MediaType.

The CharSet property is one name/value pair. The CharSet property is a shortcut to access the value of the entry in the Parameters list whose name is charset.

Methods

Parse(String) Parse(String) Parse(String) Parse(String)

Converts a string to an HttpMediaTypeHeaderValue instance.

public : static HttpMediaTypeHeaderValue Parse(PlatForm::String input)public static HttpMediaTypeHeaderValue Parse(String input)Public Static Function Parse(input As String) As HttpMediaTypeHeaderValue// You can use this method in JavaScript.
Parameters
input
PlatForm::String String String String

A string that represents the media-type and character set information used in the Content-Type HTTP header.

Returns

Remarks

Below are the exceptions that this function throws.

E_INVALIDARG

The input parameter is null (Nothing in Visual Basic).

The input parameter is not valid media-type and character set information.

ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpMediaTypeHeaderValue object.

public : PlatForm::String ToString()public string ToString()Public Function ToString() As string// You can use this method in JavaScript.
Returns
PlatForm::String string string string

A string that represents the current object.

TryParse(String, HttpMediaTypeHeaderValue) TryParse(String, HttpMediaTypeHeaderValue) TryParse(String, HttpMediaTypeHeaderValue) TryParse(String, HttpMediaTypeHeaderValue)

Determines whether a string is valid HttpMediaTypeHeaderValue information.

public : static PlatForm::Boolean TryParse(PlatForm::String input, HttpMediaTypeHeaderValue mediaTypeHeaderValue)public static bool TryParse(String input, HttpMediaTypeHeaderValue mediaTypeHeaderValue)Public Static Function TryParse(input As String, mediaTypeHeaderValue As HttpMediaTypeHeaderValue) As bool// You can use this method in JavaScript.
Parameters
input
PlatForm::String String String String

The string to validate.

Returns
PlatForm::Boolean bool bool bool

true if input is valid HttpMediaTypeHeaderValue information; otherwise, false.