.NET Framework Class Library
HttpCacheValidateHandler Delegate
Represents a method that is called to validate a cached item before the item is served from the cache.
Assembly: System.Web (in System.Web.dll)
Syntax
Visual Basic
Public Delegate Sub HttpCacheValidateHandler ( _ context As HttpContext, _ data As Object, _ ByRef validationStatus As HttpValidationStatus _ )
C#
public delegate void HttpCacheValidateHandler( HttpContext context, Object data, ref HttpValidationStatus validationStatus )
Visual C++
public delegate void HttpCacheValidateHandler( HttpContext^ context, Object^ data, HttpValidationStatus% validationStatus )
F#
type HttpCacheValidateHandler = delegate of context:HttpContext * data:Object * validationStatus:HttpValidationStatus byref -> unit
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.
Remarks
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.
Examples
The following code example demonstrates how to add a new cache validation delegate to an application.
Visual Basic
Private Sub Page_Load(sender As Object, e As EventArgs) Response.Cache.AddValidationCallback(New HttpCacheValidateHandler(AddressOf CacheValidate1), Nothing) End Sub Public Sub CacheValidate1(context As HttpContext, data As Object, ByRef status As HttpValidationStatus) If context.Request.QueryString("Valid") = "false" Then status = HttpValidationStatus.Invalid Else status = HttpValidationStatus.Valid End If End Sub
C#
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; } }
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also