Thuộc tính loại nội dung ASP


❮ Tham chiếu đối tượng phản hồi hoàn chỉnh

Thuộc tính ContentType đặt kiểu nội dung HTTP cho đối tượng phản hồi.


Cú pháp

response.ContentType[=contenttype]

Parameter Description
contenttype A string describing the content type.

For a full list of content types, see your browser documentation or the HTTP specification.


Các ví dụ

Nếu một trang ASP không có bộ thuộc tính ContentType, thì tiêu đề loại nội dung mặc định sẽ là:

content-type:text/html

Một số giá trị ContentType phổ biến khác:

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

Ví dụ này sẽ mở một bảng tính Excel trong trình duyệt (nếu người dùng đã cài đặt 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>

❮ Tham chiếu đối tượng phản hồi hoàn chỉnh