Defines the type of document being sent as response. Browsers and other programs can use this value to determine the appropriate rendering of a document.
Syntax
Response.ContentType = cContentType
Description
Whenever you double-click a file from the Windows Explorer to open it, Windows uses the file extension to determine the file type. On the basis of the file extension the relevant program is launched. Where files have no extensions or the extension is not registered in Windows, you the user will have to decide which application should open the file. Windows cannot necessarily determine the document type on the basis of the file content.
Browser can also handle various file types. Even older browsers support at least HTML documents and some imaging formats. Modern browsers can be extended to display different file types including PDF files, Flash animations etc. directly in the browser.
Those are the document types that you can send to the client through AFP documents. All AFP documents – irrespective of the content actually transmitted– most likely have either .afp or .html as file extensions. For this reason the browser cannot use the file extension as a criterion for determining the file type.
This function is taken over by the ContentType HTTP Header. To control this header, you should assign ContentType the appropriate MIME type that describes the content of the response buffer.
The MIME type is a standardized description of contents, similar to file extensions under Windows. In contrast to the latter, though, the MIME type is platform independent. MIME types consist of two information components separated by a slash.
The first component is the media type. RFC 2046 defines the few available media types. In essence, they are text for any kind of text, audio for all audio documents, image for images, video for any kind of animated image file, and application for application-specific binary data.
The default value of AFP is text/html. Generally you use AFP to create HTML documents that are made up entirely of text. For XML, on the other hand, you would use text/xml:
<%
Response.ContentType = "text/xml"
%>
In the table below you find a selection of frequent MIME types:
|
MIME ContentType |
Description |
|
text/html |
HTML (Hypertext Transfer Protocol) |
|
text/xml |
XML (Extensible MarkUp Language) |
|
text/vnd.wap.wml |
WAP (Wireless Application Protocol). Pages for display on mobile devices including cellular phones. |
|
text/plain |
Normal text. The Content-Encoding information determines the codepage to be used for the interpretation of the text file. |
|
text/richtext |
A text file in RTF format |
|
application/pdf |
PDF document that can be viewed with Adobe Acrobat Reader™. |
|
application/octet-stream |
Strictly binary data, including applications that are offered for download |
|
application/msword |
Microsoft Word for Windows document |
|
application/rtf |
A text file in RTF format |
|
application/zip |
ZIP archive |
|
application/ vnd.ms-excel |
Microsoft Excel file |
|
application/excel |
Microsoft Excel file |
|
audio/mpeg |
MP3 file |
|
image/jpeg |
JPEG images |
|
image/png |
Images in PNG format |
|
image/bmp |
Images in Windows BMP format. Not all browser are capable of displaying files in this format. |
See also
Response.AddHeader()