Class MimeType
Provides constants for commonly-used MIME types and association between file extensions and MIME types.
Inherited Members
Namespace: EmbedIO
Syntax
public static class MimeType
Fields
Default
The default MIME type for data whose type is unknown,
i.e. application/octet-stream
.
Declaration
public const string Default = "application/octet-stream"
Field Value
Type | Description |
---|---|
String |
Html
The MIME type for HTML, i.e. text/html
.
Declaration
public const string Html = "text/html"
Field Value
Type | Description |
---|---|
String |
Json
The MIME type for JSON, i.e. application/json
.
Declaration
public const string Json = "application/json"
Field Value
Type | Description |
---|---|
String |
PlainText
The MIME type for plain text, i.e. text/plain
.
Declaration
public const string PlainText = "text/plain"
Field Value
Type | Description |
---|---|
String |
Properties
Associations
Associates file extensions to MIME types.
Declaration
public static IReadOnlyDictionary<string, string> Associations { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<String, String> |
Remarks
The list of MIME types has been copied from Samuel Neff's MIME Type Map on February 14th, 2020.
Copyright (c) 2014 Samuel Neff. Redistributed under MIT license.
Methods
IsInRange(String, String)
Matches the specified MIME type to a media range.
Declaration
public static bool IsInRange(string mimeType, string mediaRange)
Parameters
Type | Name | Description |
---|---|---|
String | mimeType | The MIME type to match. |
String | mediaRange | The media range. |
Returns
Type | Description |
---|---|
Boolean | true if |
IsMimeType(String, Boolean)
Determines whether the specified string is a valid MIME type or media range.
Declaration
public static bool IsMimeType(string value, bool acceptMediaRange)
Parameters
Type | Name | Description |
---|---|---|
String | value | The value. |
Boolean | acceptMediaRange | If set to true, both media ranges
(e.g. |
Returns
Type | Description |
---|---|
Boolean | true if |
Split(String)
Splits the specified MIME type or media range into type and subtype.
Declaration
public static (string Type, string Subtype) Split(string mimeType)
Parameters
Type | Name | Description |
---|---|---|
String | mimeType | The MIME type or media range to split. |
Returns
Type | Description |
---|---|
ValueTuple<String, String> | A tuple of type and subtype. |
StripParameters(String)
Strips parameters, if present (e.g. ; encoding=UTF-8
), from a MIME type.
Declaration
public static string StripParameters(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | The MIME type. |
Returns
Type | Description |
---|---|
String |
|
Remarks
This method does not validate value
: if it is not
a valid MIME type or media range, it is just returned unchanged.