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)

'Declaration
Public Delegate Sub HttpCacheValidateHandler ( _
	context As HttpContext, _
	data As Object, _
	ByRef validationStatus As HttpValidationStatus _
)
'Usage
Dim instance As New HttpCacheValidateHandler(AddressOf HandlerMethod)
/** @delegate */
public delegate void HttpCacheValidateHandler (
	HttpContext context, 
	Object data, 
	/** @ref */ HttpValidationStatus validationStatus
)
JScript supports the use of delegates, but not the declaration of new ones.

Parameters

context

The HttpContext object containing information about the current request.

data

User-supplied data used to validate the cached item.

validationStatus

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 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
    

    private void Page_Load(Object sender, EventArgs e)
    {
        get_Response().get_Cache().AddValidationCallback(
            new HttpCacheValidateHandler(CacheValidate1), null);
    } //Page_Load

    public void CacheValidate1(HttpContext context, Object data,
        /**@ref*/HttpValidationStatus status)
    {
        if (context.get_Request().get_QueryString().get_Item("Valid").
            Equals("false")) {
            status = HttpValidationStatus.Invalid;
        }
        else {
            status = HttpValidationStatus.Valid;
        }
    } //CacheValidate1
} //Page1 

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:
© 2014 Microsoft