Map a File Extension to Content-Type (Compact 2013)
3/26/2014
The HTTP response header, called Content-Type, specifies the type of data that is being returned to the client in the response body. The client can parse the Content-Type header to determine what action to take. For instance, a web browser that receives Content-Type: text/xml can launch an XML viewer.
ISAPI extensions, filters, and ASP pages may set the Content-Type: header programmatically. The web server supports automatically mapping file extensions to Content-Type response headers for static files. A file extension is mapped to a specific content type by using the following registry entry.
[HKEY_CLASSES_ROOT\.FileExtension]
"Content Type"=REG_SZ: "type to return"
For example, to have .xml files, always have a Content-Type:text/xml create the following registry entry.
[HKEY_CLASSES_ROOT\.xml
"Content Type"="text/xml"
The web server does not cache file extension mappings. If a change is made to a file extension in the registry, the web server does not need to be restarted. It will automatically use the new mapping the next time it services a request for a given file type.
If no content type is specified in the registry for a static file of a particular extension, then by default the web server returns Content-Type:text/html. The web server will not automatically add a Content-Type: header for ISAPI extensions, filters, or ASP pages. If this value is desired, the script must be used to set it.