خاصية ContentType لـ ASP
يضبط خاصية ContentType HTTP نوع المحتوى لجسم الاستجابة.
القواعد النحوية:
response.ContentType[=contenttype]
المواضيع | وصف |
---|---|
contenttype |
وصف سلسلة أنواع المحتوى. للحصول على قائمة شاملة من أنواع المحتوى، يرجى الرجوع إلى وثائق متصفحك أو معيار HTTP. |
مثال
إذا لم يتم تعيين خاصية ContentType لصفحة ASP، فإن رأس 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>