Setting Content Type

Overview

This is an example of a script that uses the Response.ContentType property to explicitly declare to the client browser the content-type of the response. Most simple HTML pages, as well as this sample, are assumed to be of the text/html content type. Sometimes, however, you will need to override this and force the browser to treat the file as a different type.

Remarks

It is possible to set the Response.ContentType property with the value text/plain, so that your ASP script is treated as a plain text file. Theoretically, no processing would then be done by your browser, and the entire file (minus server-side scripting) would be sent to you, HTML tags and all. It is important to note, however, that some browsers, including Internet Explorer 3.0, will automatically assume the content-type to be text/html of any file that contains an <HTML>, <HEAD>, or <BODY> tag, no matter what the content-type you explicitly set with Response.ContentType.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\interaction\ContentType_VBScript.asp and ...\asp\interaction\ContentType_JScript.asp.