Sideway
output.to from Sideway
Draft for Information Only

Content

Response Object
Response.ContentType Property
   Syntax:
   Parameters:
   Remarks:
   Examples:
Response.Charset Property
   Syntax:
   Parameters:
   Remarks:
   Examples:

Response Object

Another important function of Response object is the output of HTTP headers to the client. As part of the HTTP header, these types of response objects should be sent before sending any body content to the client.

Response.ContentType Property

Response.ContentType sets the value of content-type header to specify the content type of the HTTP response .

Syntax:

Response.ContentType [=Content Type]

 Or in an ASP file. Imply

<% Response.Charset = Content Type %>

Parameters:

Content Type

The parameter "Content Type" is the value of the content-type header. The data type of "Content Type" is strings of format "type/subtype" and the value must be enclosed in quotation marks (" "). "type" is the general content category and "subtype" is the specific content type. The possible values of "Content Type" are

Type Type/Subtype
text : textual information text/plain : textual data
text/html : HTML
text/css : Cascading Style Sheets
text/xml : Extensible Markup Language
image : image data image/gif : GIF image
image/jpeg : JPEG image
image/png : Portable Network Graphics
image/tiff : Tag Image File Format
image/svg+xml : SVG vector image
audio : audio data audio/mp4 : MP4 audio
audio/mpeg : MP3 audio
audio/ogg : Ogg
video : video data video/mpeg : MPEG-1
video/mp4 : MP4
video/quicktime : QuickTime video
video/ogg : Ogg video
application : processed data application/pdf : Portable Document Format
application/xhtml+xml : XHTML

Remarks:

In general, the default value of the Content Type parameter is "text/html" if there is  Content Type property is not set for the page.

Since each page can only be assigned to one Content Type, the last instance of Response.ContentType in the HTTP header setting of a ASP file will replace all previous Response.ContentType Setting.

If the response buffering is not enbled, the ContentType header setting must be set before any response is sent to the client.

Examples:

  • Default value with No Response.ContentType propertye property

    ASP script command:

    <%  %>

    HTTP header response:

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.ContentType with value "image/jpeg"

    ASP script command:

    <% Response.Charset = "image/jpeg" %>

    HTTP header response: 

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: image/jpeg
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Multi Response.Charset with value "image/jpeg" and "text/html"

    ASP script command:

    <% Response.Charset = "image/jpeg" %>
    <% Response.ContentType = "text/html" %> 

    HTTP header response: response: 

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/PPP; path=/
    Cache-control: private

Response.Charset Property

Response.Charset property appends the name of character set to the charset parameter in the content-type header to specify the character encoding of the response contents for the browser.

Syntax:

Response.Charset (CharsetName)

 Or in an ASP file. Imply

<% Response.Charset = CharsetName  %>

Parameters:

CharsetName

The parameter "CharsetName" is the value of the Character set name appended to the charset parameter of the content-type header. The data type of "CharsetName" is strings and the value must be enclosed in quotation marks (" "). The possible values of "CharsetName" are

ValueDescription
US-ASCIIANSI_X3.4-1968
ISO-8859-1ISO_8859-1:1987
ISO-8859-2ISO_8859-2:1987
ISO-8859-3ISO_8859-3:1988
ISO-8859-4ISO_8859-4:1988
ISO-8859-5ISO_8859-5:1988
ISO-8859-6ISO_8859-6:1987
ISO-8859-7ISO_8859-7:1987
ISO-8859-8ISO_8859-8:1988
ISO-8859-9ISO_8859-9:1989
ISO-8859-10ISO_8859-10:1992
Shift_JISShift_JIS
EUC-JP Extended_UNIX_Code_Packed_Format_for_Japanese
ISO-2022-KRISO-2022-KR
EUC-KREUC-KR
ISO-2022-JPISO-2022-JP
ISO-2022-JP-2ISO-2022-JP-2
ISO-8859-6-EISO-8859-6-E
ISO-8859-6-IISO-8859-6-I
ISO-8859-8-EISO-8859-8-E
ISO-8859-8-IISO-8859-8-I
UTF-8UTF-8
ISO-8859-13ISO-8859-13
ISO-8859-14ISO_8859-14:1998
ISO-8859-15ISO-8859-15
ISO-8859-16ISO_8859-16:2001
GBKGBK
GB18030GB18030
GB2312GB2312
Big5Big5
KOI8-RKOI8-R
windows-1252windows-1252

Remarks:

Response.Charset property only appends the specified value to the charset parameter of the content-type header. There is no mechanism to validate whether the specified value represents a valid character set. And there is no browser can understand all character set.

Since each page can only be encoded in one charset, the last instance of Response.Charset in the HTTP header setting of a ASP file will replace all previous Response.charset Setting.

If the response buffering is not enbled, the Charset header setting must be set before any response is sent to the client.

The Unicode encoding, UTF-8 is one of the widely used charset to represent Unicode text in page with mixed languages

Besides, the value of CharsetName and value of codepage should match with each other. Since the code page is the value to specify the encoding code page used by the web server to general the response contents, while the character set is the value to specify the decoding character set used by the page browser. Therefore, a codepage setting, by Response.CodePage, Session.CodePage, @CodePage, or AspCodePage, is needed to ensure the readability of the displayed text. And a charsetname setting should also be used to ensure the decoding character set used in client browser match with the encoding code page used in the web server.web server.

Name of Character set can refer to http://www.iana.org/assignments/character-sets

Examples:

  • Default value with No Response.Charset property

    ASP script command:

    <%  %>

    HTTP header response:

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Response.Charset with value "UTF-8"

    ASP script command:

    <% Response.Charset = "UTF-8" %>

    HTTP header response: 

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html; Charset=UTF-8
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private

  • Multiple Response.Charset with value "UTF-8" and "Big5"

    ASP script command:pt command:

    <% Response.Charset = "UTF-8" %>
    <% Response.Charset = "Big5" %> 

    HTTP header response: 

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET
    Content-Length: 0
    Content-Type: text/html; Charset=Big5
    Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
    Cache-control: private


©sideway

ID: 120200001 Last Updated: 2/2/2012 Revision: 1 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 224

Software

Application 213

Digitization 32

Latex 52

Manim 204

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 33

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2022 Sideway . All rights reserved Disclaimers last modified on 06 September 2019