ASP Response Object

The Response object is used to send output to the client from the web server. The syntax, collections, properties and methods of the ASP Response object are as follows:

Syntax

Response.collection|property|method

Collections

Collections Description
Cookies The Cookies collection sets the value of a cookie. If you attempt to set the value of a cookie that does not exist, it is created. If it already exists, the new value you set overwrites the old value already written to the client machine.

Properties

Properties Description
Buffer The Buffer property determines whether to buffer page output or not. If set to True, then output from the page is not sent to the client until the script on that page has been processed, or until the Response object Flush or End methods are called.
CacheControl The CacheControl property determines whether proxy servers are able to cache the output generated by ASP or not. If your page’s content is large and doesn’t change often, you might want to allow proxy servers to cache the page. In this case set this property to Public. Otherwise set it to Private.
Charset The Charset property appends the name of the character set to the Content-Type header in the Response object.
ContentType The ContentType property specifies the HTTP content type for the response. If not specified, the default is “text/html”.
Expires The Expires property specifies the length of time (in minutes) that the client machine will cache the current page. If the user returns to the page before it expires, the cached version will be displayed.
ExpiresAbsolute The ExpiresAbsolute property specifies a date and time on which a page cached on a browser will expire. If the user returns to the same page before that date and time, the user will view the cached version of the page. If no time is specified, the page expires at midnight on the date specified. If a date is not specified, the page expires at the given time on the day that the script is run.
IsClientConnected The IsClientConnected property is a read-only property that indicates if the client has disconnected from the web server since the last use of the Response object’s Write method.
Pics The PICS (Platform for Internet Content Selection) property adds a value to the pics-label field of the response header.
Status The Status property specifies the value of the status line that is returned to the client machine from the web server.

Methods

Methods Description
AddHeader The AddHeader method allows you to add your own HTTP header with a specified value. If you add an HTTP header with the same name as a previously added header, the second header will be sent in addition to the first; adding the second header does not overwrite the value of the first header with the same name. Also, once the header has been added to the HTTP response, it cannot be removed.
AppendToLog The AppendToLog method adds a string to the end of the Web server log entry for the current page request. You can only add up to 80 characters at a time, but you can call this method multiple times.
BinaryWrite The BinaryWrite method writes information directly to the output without any character conversion.
Clear The Clear method erases any buffered HTML output. It does so without sending any of the buffered response to the client. Calling Clear will cause an error if Buffer property of the Response object is not set to True.
End The End method stops the processing of the script in the current page and sends the already created content to the client. Any code present after the call to the End method is not processed.
Flush The Flush method sends buffered output to the client immediately. Flush will cause a run-time error if Buffer property of the Response object is not set to True.
Redirect The Redirect method redirects the user to a different URL.
Write The Write method writes a specified string to the output.

Troubleshooting with ASP Response Object

The Response object methods give you potent control over what you can send to the client from the web server. However, one of the most valuable uses for the Response object is in debugging your scripts. Let’s assume that you want to view the current value for myVar variable at a certain place in your script. You can insert the code below and view the value anywhere in your script:

Response.Clear
Response.Write "The value of strMyValue is " & strMyValue
Response.End

At first, this code clears the buffer (assumed that Buffer property is set to True). Next, it inserts a single line of text displaying your variable’s value. Finally, it completely ends processing of your server script and sends the contents of the Response object’s buffer to the client.

admin

admin

Leave a Reply

Your email address will not be published.