ویژگی ContentType ASP
ویژگی ContentType محتوای HTTP را برای شیء response تنظیم میکند.
نحوه استفاده:
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/JPEG"%>
این مثال یک جدول الکترونیکی 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>