asp.net.ph

HttpCacheValidateHandler Delegate

System.Web Namespace


Delegate method that is called when a cached item is validated. Cache items invalidated within the method are treated as cache misses.

[ VB ]
<Serializable>
public Delegate Sub HttpCacheValidateHandler ( _
   ByVal context As HttpContext, _
   ByVal data As Object, _
   ByRef validationStatus As HttpValidationStatus _
)

[ C# ]
[ Serializable ]
public delegate void HttpCacheValidateHandler (
   HttpContext context,
   object data,
   ref HttpValidationStatus validationStatus
);

[ C++ ]
[ Serializable ]
public __gc __delegate void HttpCacheValidateHandler (
   HttpContext* context,
   Object* data,
   HttpValidationStatus* validationStatus
);

In [ JScript ], you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [ Visual Basic, C#, C++ ]

The declaration of your event handler must have the same parameters as the HttpCacheValidateHandler delegate declaration.

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.

Remarks

If any handler invalidates the cached item, the item is evicted from the cache and the request is handled as a cache miss.

Example

The following example adds a new cache validation delegate to an aplication.

[ VB ]

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 src, 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;
  }
}
See Also

HttpCachePolicy Class Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph