HttpCachePolicy.AddValidationCallback Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a validation callback for the current response.
public:
void AddValidationCallback(System::Web::HttpCacheValidateHandler ^ handler, System::Object ^ data);
public void AddValidationCallback(System.Web.HttpCacheValidateHandler handler, object data);
member this.AddValidationCallback : System.Web.HttpCacheValidateHandler * obj -> unit
Public Sub AddValidationCallback (handler As HttpCacheValidateHandler, data As Object)
Parameters
- handler
- HttpCacheValidateHandler
The HttpCacheValidateHandler value.
- data
- Object
The arbitrary user-supplied data that is passed back to the AddValidationCallback(HttpCacheValidateHandler, Object) delegate.
Exceptions
The specified handler is null.
Examples
The following code example demonstrates how to add a delegate to validate a request based on query string values.
<%@ Page Language="C#" %>
<%@ OutputCache VaryByParam="none" Duration="600" %>
<%@ Page Language="VB" %>
<%@ OutputCache VaryByParam="none" Duration="600" %>
Remarks
The AddValidationCallback method provides a mechanism to check the response programmatically in the cache before the response is returned to the client by the output cache.
Before the response is served from the Web server cache, all registered handlers are queried to ensure resource validity. If any handler sets a flag indicating that the cached response is not valid, the entry is marked as not valid and expelled from the cache. In this case, as well as when any handler indicates that the cached response should be ignored for this request, the request is then handled as if it were a cache miss.
AddValidationCallback is introduced in the .NET Framework version 3.5. For more information, see Versions and Dependencies.