ASP ContentType 屬性

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/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>
<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>
