The ASP Response Object is one of the most used objects in an ASP application. You use the Response object when you need to send information
to the user accessing your web page. The Response object is also commonly used to redirect your visitor to other web pages directly without
the need for client-side scripting. The syntax, collections, properties and methods of the ASP Response object are as follows:
<%
Response.collection|property|method
%>
Collections
Collection | Description |
Cookies | Sets the value of a cookie. If the cookie does not exist, it is created and the value is assigned. If it already exists, the new value you set overwrites the old value. |
Properties
Property | Description |
Buffer | Specifies whether to buffer the page output or not. If True, then output 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 | Sets whether a proxy server can cache the output generated by ASP or not. Private is default and proxy servers will not cache pages with this setting. Public will allow proxy servers to cache the page. |
Charset | Appends the name of a character-set to the content-type header in the Response object. |
ContentType | Sets the HTTP content type for the Response object. Default is "text/html". |
Expires | Sets how long, in minutes, a page will be cached on a browser before it expires. |
ExpiresAbsolute | Sets a date and time when a page cached on a browser will expire. |
IsClientConnected | Indicates if the client has disconnected from the server. |
Pics | Appends a value to the PICS label response header. |
Status | Specifies the value of the status line returned by the server. |
Methods
Method | Description |
AddHeader | Add your own HTTP header with a specified value. |
AppendToLog | Adds a string to the end of the Web server log entry for the current page request. |
BinaryWrite | Writes information directly to the output without any character conversion. |
Clear | Clears any buffered HTML output |
End | Stops processing a script, and returns the current result |
Flush | Sends buffered HTML output immediately |
Redirect | Redirects the user to a different URL |
Write | Writes a specified string to the output |
Examples
Here is a listing of some examples regarding the use of the Response Object and its collections, methods, and properties.
<%
Response.Cookies("firstName")="John"
Response.Buffer=true
Response.CacheControl="Public"
Response.Charset="ISO-8859-1"
Response.ContentType="application/vnd.ms-excel"
Response.Expires=-1
Response.ExpiresAbsolute=#January 10,2013 12:00:00#
Response.Status="401 Unauthorized"
Response.AddHeader "INFO","Message text"
Response.AppendToLog "Log message"
Response.Clear
Response.End
Response.Flush
Response.Redirect("http://www.itgeared.com")
Response.Write("Hello World!")
%>
Did you find the page informational and useful? Share it using one of your favorite social sites.
Recommended Books & Training Resources