คุณสมบัติ ContentType ของ ASP

response 对象参考手册

คุณสมบัติ ContentType กำหนด HTTP Content Type ของอ象 response。

รูปแบบการใช้งาน:

response.ContentType[=contenttype]
ตัวแปร การอธิบาย
contenttype

ข้อความเล่าถึงประเภทของสิ่ง

สำหรับรายการประเภท content type ที่สมบูรณ์ โปรดดูเอกสารบราวเซอร์ของคุณหรือมาตรากฎ HTTP。

ตัวอย่าง

ถ้าหากหน้า ASP ไม่ได้ตั้งค่าค่าตัวแปร ContentType แล้ว ค่าที่ใช้เป็นค่าเริ่มต้นของ header 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 ในบราวเซอร์ (หากผู้ใช้งานได้ติดตั้ง Excel แล้ว):

<%response.ContentType="application/vnd.ms-excel"%>
<html>

1 2 3 4
5 6 7 8

response 对象参考手册