HttpCachePolicy.SetCacheability Method (HttpCacheability, String)

Sets the Cache-Control header to one of the values of HttpCacheability and appends an extension to the directive.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public:
void SetCacheability (
	HttpCacheability cacheability, 
	String^ field
)
public void SetCacheability (
	HttpCacheability cacheability, 
	String field
)
public function SetCacheability (
	cacheability : HttpCacheability, 
	field : String
)

Parameters

cacheability

The HttpCacheability enumeration value to set the header to.

field

The cache control extension to add to the header.

Exception typeCondition

ArgumentNullException

field is a null reference (Nothing in Visual Basic).

ArgumentException

cacheability is not Private or NoCache.

The field name extension is valid only when used with the private or no-cache directives. For more information, see RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, available on the World Wide Web Consortium (W3C) Web site.

This method will throw an invalid argument exception if incompatible directives and extensions are combined.

The following code example demonstrates how the Cache-Control header is set to the enumeration value private and adds a cache-control extension. The modified directive means that in addition to any non-shared cache, any cache shared only by members of the community named "DEV" may cache the response.

No code example is currently available or this language may not be supported.
get_Response().get_Cache().
    SetCacheability(HttpCacheability.Private, "Community=DEV");

Response.Cache.SetCacheability(HttpCacheability.Private, "Community=DEV")
 

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: