Did you find this useful?
Socialize it today.


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:


<%
Response.collection|property|method
%>

Collections

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


Properties

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


Methods

MethodDescription
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


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!")
%>

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

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