Export (0) Print
Expand All
Expand Minimize

HttpCacheValidateHandler Delegate

Represents a method that is called to validate a cached item before the item is served from the cache.

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

public delegate void HttpCacheValidateHandler(
	HttpContext context,
	Object data,
	ref HttpValidationStatus validationStatus
)

Parameters

context
Type: System.Web.HttpContext

The HttpContext object containing information about the current request.

data
Type: System.Object

User-supplied data used to validate the cached item.

validationStatus
Type: System.Web.HttpValidationStatus

An HttpValidationStatus enumeration value. Your delegate should set this value to indicate the result of the validation.

If a cached item is invalidated within the scope of the HttpCacheValidateHandler method, it is evicted from the cache and the request for the item is treated as a cache miss.

TopicLocation
How to: Check the Validity of a Cached PageBuilding ASP .NET Web Applications
How to: Check the Validity of a Cached PageBuilding ASP .NET Web Applications

The following code example demonstrates how to add a new cache validation delegate to an application.


private void Page_Load(Object sender, EventArgs e)
{
   Response.Cache.AddValidationCallback(new HttpCacheValidateHandler(CacheValidate1), null);
}

public void CacheValidate1(HttpContext context, Object data, ref HttpValidationStatus status) 
{
   if (context.Request.QueryString["Valid"] == "false") 
   {
      status = HttpValidationStatus.Invalid;
   }
   else 
   {
      status = HttpValidationStatus.Valid;
   }
}
    

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft