ASP ContentType属性

response オブジェクトリファレンスマニュアル

ContentType属性はresponseオブジェクトにHTTP内容型を設定します。

语法:

response.ContentType[=contenttype]
パラメータ 説明
contenttype

内容型を説明する文字列。

完全な内容型リストについては、ブラウザのドキュメントまたはHTTP規範を参照してください。

ASPページにContentType属性が設定されていない場合、デフォルトのcontent-typeヘッダーは以下のようになります:

content-type:text/html

他にも一般的に使用されるContentTypeの値があります:

<%response.ContentType="text/HTML"%>
<%response.ContentType="image/GIF"%>
<%response.ContentType="image/JPEG"%>
<%response.ContentType="text/plain"%>
<%response.ContentType="image/JPEG"%>

この例では、ブラウザでExcelエクセルシートが開かれます(ユーザーがExcelをインストールしている場合):

<%response.ContentType="application/vnd.ms-excel"%>
<html>
<body>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</table>
</body>
</html>

response オブジェクトリファレンスマニュアル