Share via


Mapping a File Extension to Content-Type (Windows Embedded CE 6.0)

1/6/2010

The HTTP response header Content-Type specifies the type of the data that is being returned to the client in the response body. The client may parse the Content-Type header to determine what action to take. For instance, a Web browser that receives Content-Type: text/xml may decide to 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. It is the script's responsibility to set this value, if desired.

See Also

Concepts

HTTP Implementation