MimeContentTypes
This class allows you to access standard MIME type in your program. Supported MIME types are:
| Property | Description |
|---|
| Csv | Returns "text/csv" |
| Excel | Returns "application/vnd.ms-excel" |
| Form | Returns "application/x-www-form-urlencoded" |
| Html | Returns "text/html" |
| Image_Png | Returns "image/png" |
| Image_Gif | Returns "image/gif" |
| Image_Jpg | Returns "image/jpeg" |
| Javascript | Returns "application/javascript" |
| Json | Returns "application/json" |
| Pdf | Returns "application/pdf" |
| Text | Returns "text/plain" |
| Unknown | Returns "application/octet-stream" |
| Word (doc) | Returns "application/ms-word" |
| Word (docx) | Returns "application/vnd.openxmlformats-officedocument.wordprocessingml.document" |
| Xml | Returns "application/xml" |
| XmlText | Returns "application/xml; encoding='utf-8'" |
An example of passing MIME type to "File" response is below:
public ActionResponse Index()
{
byte[] fileContents = PdfGenerator.Generate("<h1>Hello World</h1>");
return File(fileContents, MimeContentTypes.Pdf);
}