ASP ContentType 屬性
response 對(duì)象參考手冊(cè)ContentType 屬性為 response 對(duì)象設(shè)置 HTTP 內(nèi)容類型。
語(yǔ)法:
response.ContentType[=contenttype]
參數(shù) | 描述 |
---|---|
contenttype | 描述內(nèi)容類型的字符串。 如需完整的內(nèi)容類型列表,請(qǐng)參閱您的瀏覽器文檔或 HTTP 規(guī)范。 |
實(shí)例
如果 ASP 頁(yè)面沒(méi)有設(shè)置 ContentType 屬性,那么默認(rèn)的 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"%>
此例會(huì)在瀏覽器中打開(kāi)一個(gè) Excel 電子表格(如果用戶已經(jīng)安裝了 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 對(duì)象參考手冊(cè)