The Response object is an instance of the System.Web.HttpResponse class.
Response object of ASP.Net is related to sending response from the server to the
client. The Response object becomes less importance because the ASP.NET server side objects also have object oriented methods for rendering the response page.
In code, the HttpResponse object is referred to by the keyword Response. For example, Response.Clear() refers to the HttpResponse.Clear method. The Page class has a property that is named Response that exposes the current instance of HttpResponse.
The methods and properties of the HttpResponse class are exposed through the Response property of the HttpApplication, HttpContext, Page, and UserControl classes.
Constructor
Constructor
Description
HttpResponse(TextWriter)
Initializes a new instance of the HttpResponse class.
Properties
Property
Description
Buffer
Gets or sets a value indicating whether to buffer output and send it after the complete response is finished processing.
BufferOutput
Gets or sets a value indicating whether to buffer output and send it after the complete page is finished processing.
Cache
Gets the caching policy (such as expiration time, privacy settings, and vary clauses) of a Web page.
CacheControl
Gets or sets the Cache-Control HTTP header that matches one of the HttpCacheability enumeration values.
Charset
Gets or sets the HTTP character set of the output stream.
CodePage
Set the value of code page for the data of response in the intrinsic objects to
specify the character encoding for different languages in the server
ContentEncoding
Gets or sets the HTTP character set of the output stream.
ContentType
Set the value of content-type header to specify the content type of the HTTP
response
Cookies (collection)
Gets the response cookie collection.
Expires
Gets or sets the number of minutes before a page cached on a browser expires. If the user returns to the same page before it expires, the cached version is displayed. Expires is provided for compatibility with earlier versions of ASP.
ExpiresAbsolute
Gets or sets the absolute date and time at which to remove cached information from the cache. ExpiresAbsolute is provided for compatibility with earlier versions of ASP.
Filter
Gets or sets a wrapping filter object that is used to modify the HTTP entity body before transmission.
HeaderEncoding
Gets or sets an Encoding object that represents the encoding for the current header output stream.
Headers
Gets the collection of response headers.
IsClientConnected
Gets a value indicating whether the client is still connected to the server.
IsRequestBeingRedirected
Gets a Boolean value indicating whether the client is being transferred to a new location.
LCID
Set the value of
LCID for the data of response output to
specify the format of dates, times, and currency for different geographical
locale for the server
Output
Enables output of text to the outgoing HTTP response stream.
OutputStream
Enables binary output to the outgoing HTTP content body.
PICS
Set the value of PICS label for the pics-label header to specify the content
rating.
RedirectLocation
Gets or sets the value of the HTTP Location header.
Status
Sets the Status line that is returned to the client.
StatusCode
Gets or sets the HTTP status code of the output returned to the client.
StatusDescription
Gets or sets the HTTP status string of the output returned to the client.
SubStatusCode
Gets or sets a value qualifying the status code of the response.
SuppressContent
Gets or sets a value indicating whether to send HTTP content to the client.
TrySkipIisCustomErrors
Gets or sets a value that specifies whether IIS 7.0 custom errors are disabled.
Methods
Method
Description
AddCacheDependency(CacheDependency[])
Associates a set of cache dependencies with the response to facilitate invalidation of the response if it is stored in the output cache and the specified dependencies change.
AddCacheItemDependencies(ArrayList)
Makes the validity of a cached response dependent on other items in the cache.
AddCacheItemDependencies(String[])
Makes the validity of a cached item dependent on another item in the cache.
AddCacheItemDependency(String)
Makes the validity of a cached response dependent on another item in the cache.
AddFileDependencies(ArrayList)
Adds a group of file names to the collection of file names on which the current response is dependent.
AddFileDependencies(String[])
Adds an array of file names to the collection of file names on which the current response is dependent.
AddFileDependency(String)
Adds a single file name to the collection of file names on which the current response is dependent.
AddHeader(String, String)
Adds an HTTP header to the output stream. AddHeader(String, String) is provided for compatibility with earlier versions of ASP.
AppendCookie(HttpCookie)
Adds an HTTP cookie to the intrinsic cookie collection.
AppendHeader(String, String)
Adds an HTTP header to the output stream.
AppendToLog(String)
Adds custom log information to the Internet Information Services (IIS) log file.
ApplyAppPathModifier(String)
Adds a session ID to the virtual path if the session is using Cookieless session state and returns the combined path. If Cookieless session state is not used, ApplyAppPathModifier(String) returns the original virtual path.
BinaryWrite(Byte[])
Writes a string of binary characters to the HTTP output stream.
Clear()
Clears all content output from the buffer stream.
ClearContent()
Clears all content output from the buffer stream.
ClearHeaders()
Clears all headers from the buffer stream.
Close()
Closes the socket connection to a client.
DisableKernelCache()
Disables kernel caching for the current response.
End()
Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.
Equals(Object)
Determines whether the specified object is equal to the current object. (Inherited from Object)
Flush()
Sends all currently buffered output to the client.
GetHashCode()
Serves as the default hash function. (Inherited from Object)
GetType()
Gets the Type of the current instance. (Inherited from Object)
MemberwiseClone()
Creates a shallow copy of the current Object. (Inherited from Object)
Pics(String)
Appends a HTTP PICS-Label header to the output stream.
Redirect(String)
Redirects a request to a new URL and specifies the new URL.
Redirect(String, Boolean)
Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
RemoveOutputCacheItem(String)
Removes from the cache all cached items that are associated with the default output-cache provider. This method is static.
SetCookie(HttpCookie)
Because the HttpResponse.SetCookie method is intended for internal use only, you should not call it in your code. Instead, you can call the HttpResponse.Cookies.Set method, as the following example shows. Updates an existing cookie in the cookie collection.
ToString()
Returns a string that represents the current object. (Inherited from Object)
TransmitFile(String)
Writes the specified file directly to an HTTP response output stream, without buffering it in memory.
TransmitFile(String, Int64, Int64)
Writes the specified part of a file directly to an HTTP response output stream without buffering it in memory.
Write(Char)
Writes a character to an HTTP response output stream.Writes a character to an HTTP response output stream.
Write(Char[], Int32, Int32)
Writes an array of characters to an HTTP response output stream.
Write(Object)
Writes an Object to an HTTP response stream.
Write(String)
Writes a string to an HTTP response output stream.
WriteFile(IntPtr, Int64, Int64)
Writes the specified file directly to an HTTP response output stream.
WriteFile(String)
Writes the contents of the specified file directly to an HTTP response output stream as a file block.
WriteFile(String, Boolean)
Writes the contents of the specified file directly to an HTTP response output stream as a memory block.
WriteFile(String, Int64, Int64)
Writes the specified file directly to an HTTP response output stream.
Allows insertion of response substitution blocks into the response, which allows dynamic generation of specified response regions for output cached responses.
Remarks
The
methods and properties of ASP response object can be grouped into