| |||||
HttpCacheValidateHandler DelegateDelegate 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.
RemarksIf any handler invalidates the cached item, the item is evicted from the cache and the request is handled as a cache miss. ExampleThe 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 |
| ||||
Check out related books at Amazon
© 2000-2008 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 aspxtreme