Table of Contents

Class MediaTypeHeaderValue

Namespace
System.Net.Http.Http.Headers
Assembly
System.Net.Http.dll

Represents a media type used in a Content-Type header as defined in the RFC 2616.

public class MediaTypeHeaderValue
Inheritance
MediaTypeHeaderValue
Inherited Members
Extension Methods

Remarks

The MediaTypeHeaderValue class provides support for the media type used in a Content-Type header as defined in RFC 2616 by the IETF. An example of a media-type would be "text/plain; charset=iso-8859-5".

Constructors

MediaTypeHeaderValue(string)

Initializes a new instance of the MediaTypeHeaderValue class.

public MediaTypeHeaderValue(string mediaType)

Parameters

mediaType string

The source represented as a string to initialize the new instance.

Exceptions

ArgumentException

If mediaType parameter is null or empty

FormatException

If mediaType parameter contains invalid value for MediaType.

Properties

CharSet

Gets or sets the character set.

public string CharSet { get; set; }

Property Value

string

The character set.

MediaType

Gets or sets the media-type header value.

public string MediaType { get; set; }

Property Value

string

The media-type header value.

Remarks

The media-type is used in the Content-Type and Accept header fields in order to provide open and extensible data typing and type negotiation.

Methods

Parse(string)

Converts a string to an MediaTypeHeaderValue instance.

public static MediaTypeHeaderValue Parse(string input)

Parameters

input string

A string that represents media type header value information.

Returns

MediaTypeHeaderValue

A MediaTypeHeaderValue instance.

Exceptions

FormatException

input is not valid media type header value information.

ArgumentNullException

input is a null reference.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Remarks

Available only in mscorlib build with support for System.Reflection.