ASP Response Object

Tuesday, August 28, 2012

tags ASP

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:



CookiesSets 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.


BufferSpecifies 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.
CacheControlSets 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.
CharsetAppends the name of a character-set to the content-type header in the Response object.
ContentTypeSets the HTTP content type for the Response object. Default is "text/html".
ExpiresSets how long, in minutes, a page will be cached on a browser before it expires.
ExpiresAbsoluteSets a date and time when a page cached on a browser will expire.
IsClientConnectedIndicates if the client has disconnected from the server.
PicsAppends a value to the PICS label response header.
StatusSpecifies the value of the status line returned by the server.


AddHeaderAdd your own HTTP header with a specified value.
AppendToLogAdds a string to the end of the Web server log entry for the current page request.
BinaryWriteWrites information directly to the output without any character conversion.
ClearClears any buffered HTML output
EndStops processing a script, and returns the current result
FlushSends buffered HTML output immediately
RedirectRedirects the user to a different URL
WriteWrites a specified string to the output


Here is a listing of some examples regarding the use of the Response Object and its collections, methods, and properties.

Response.ExpiresAbsolute=#January 10,2013 12:00:00#
Response.Status="401 Unauthorized"
Response.AddHeader "INFO","Message text"
Response.AppendToLog "Log message"
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

Sams Teach Yourself Active Server Pages 3.0 in 21 Days ASP In A Nutshell Beginning ASP Databases