ASP.NET response filtering and post-cache substitution are not compatible


Consider the following scenario:

  1. You have an ASP.NET application running on Internet Information Services 6.0 or Internet Information Services 7.0. 
  2. The application uses post-cache substitution.
  3. The application also uses an HTTP filter module to filter out rendered content.


In this scenario, the following problems may occur:

  • If the application is hosted on IIS7 in Classic Pipeline mode, or on IIS6, the substitution blocks are only rendered on the first request. Subsequent page accesses cause the full page to be served from the output cache and the substitution blocks to not be updated.



  • If the application is hosted on IIS7 in Integrated Pipeline mode, an exception of type System.InvalidOperationException occurs with the following details:

Exception Details: System.InvalidOperationException: Post cache substitution is not compatible with modules in the IIS integrated pipeline that modify the response buffers.  Either a native module in the pipeline has modified an HTTP_DATA_CHUNK structure associated with a managed post cache substitution callback, or a managed filter has modified the response.



Response filtering and post-cache substitution are not compatible.



To avoid the problem, choose one of the following options:

  1. Disable output caching on pages that are using substitution blocks.


  2. Do not use the response filter module.

More Information

Post-cache substitution is implemented using a list of substitution blocks (.NET delegates) used to reconstruct individual pieces of the response. ASP.NET internally maintains a list of HTTP_DATA_CHUNK structures associated with a managed post-cache substitution callback.  When a response filter is used, a raw response is rendered into a single buffer and the list of substitution blocks is lost.  Therefore, the substitution blocks cannot be rendered.

For more information on post-cache substitution, please see:


Caching Portions of an ASP.NET Page



Article ID: 2014472 - Last Review: Feb 5, 2010 - Revision: 1