Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [342]

By Root 5639 0

}

Response filters provide an interesting opportunity for developers to build more powerful applications, but I caution you to be careful when considering this option. As the sample demonstrates, changing the case of the entire output is not a smart move. If done without care, the change ends up affecting the view state and the internal script code, both of which consist of case-sensitive text, seriously compromising the functionality of the page. Second, filters must be activated on a per-page basis. If you need to filter all the pages in a Web site, you’re better off writing an HTTP module.

Methods of the HttpResponse Class


Table 16-11 lists all the methods defined on the HttpResponse class.

Table 16-11. HttpResponse Methods

Method

Description

AddCacheDependency

Adds an array of cache dependencies to make the cached page output invalid if any dependency gets broken. In the array, you can have any class that inherits from CacheDependency.

AddCacheItemDependencies

Adds an array of strings representing names of items in the ASP.NET Cache. When any of the specified items vary, the cached page output becomes invalid.

AddCacheItemDependency

Description is the same as for the previous item, except that AddCacheItemDependency adds a single cache item name.

AddFileDependencies

Adds a group of file names to the collection of file names on which the current page is dependent. When any of the files are modified, the cached output of the current page is deemed invalid.

AddFileDependency

Adds a single file name to the collection of file names on which the current page is dependent. If the file is modified, the cached output of the current page becomes invalid.

AddHeader

Adds an HTTP header to the output stream. It is provided for compatibility with previous versions of ASP. In ASP.NET, you should use AppendHeader.

AppendCookie

Adds an HTTP cookie to the cookie collection.

AppendHeader

Adds an HTTP header to the output stream.

AppendToLog

Adds custom log information to the IIS log file.

ApplyAppPathModifier

Adds a session ID to the specified virtual path, and returns the result. It is mostly used with cookieless sessions to construct absolute HREFs for hyperlinks.

BinaryWrite

Writes binary characters to the HTTP output stream. It is subject to failures with very large files. (See the references to this method later in the chapter.)

Clear

Clears all content output from the buffer stream.

ClearContent

Calls into Clear.

ClearHeaders

Clears all headers from the buffer stream.

Close

Closes the socket connection with the client.

DisableKernelCache

Disables kernel caching for the current response. If kernel caching is not supported, the method has no effect.

End

Sends all buffered text to the client, stops execution, and raises the end event for the request.

Flush

Sends all currently buffered output to the client.

Pics

Appends a PICS-Label HTTP header to the output. PICS stands for Platform for Internet Content Selection and is a World Wide Web Consortium (W3C) standard for rating pages. Any string is acceptable as long as it doesn’t exceed 255 characters.

Redirect

Redirects a client to a new URL. It needs a roundtrip. The browser receives an HTTP 302 status code, meaning that the resource has been temporarily moved.

RedirectPermanent

Redirects a client to a new URL. It needs a roundtrip. The browser receives an HTTP 301 status code, meaning that the resource has been permanently moved to a new location.

RedirectToRoute

Redirects a client to a URL specified as a route. The method works if Web Forms routing is used to specify routes.

RemoveOutputCacheItem

A static method that takes a file system path and removes from the cache all cached items associated with the specified path.

SetCookie

Updates an existing cookie in the cookie collection.

TransmitFile

Just like BinaryWrite and WriteFile, it writes the specified file directly to the output stream. You can safely use TransmitFile regardless of the size of the file that you want

Return Main Page Previous Page Next Page

®Online Book Reader