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"%>
此示例將在瀏覽器中開啟一個 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 物件參考