Post-Cache Substitution


ASP.NET 2.0 now supports post-cache substitution, which allows you to configure a section in a page as non-cacheable. Therefore, although the page is cached, parts of it will be re-processed when the page is requested again. For example, you can create a cached page with mostly static content but that displays the user’s name in a Label control. Without post-cache substitution, the user name would remain the same for all requests. With post-cache substitution, you can mark the page as cacheable and put the Label control inside another control marked as not cacheable. The user name will then refresh each time the page is requested

 AdRotator Support for Post-Cache Substitution

Although it is possible to insert dynamic content from user code as demonstrated in the examples above, the most common way that page developers will access post-cache substitution behavior is through ASP.NET server controls that implement direct support for it. For example, the ASP.NET AdRotator control implements support for post-cache substitution in order to render unique Advertisements on each request, regardless of whether the parent page is cached.

<%@ OutputCache Duration="60" VaryByParam="none" %>

<form runat="server">

<asp:AdRotator AdvertisementFile="Ads.xml" runat="server"/>


Internally, the AdRotator creates a standalone in-memory object with a single callback method that can render Ad content, to be passed as the delegate to the Response.WriteSubstitution method. This render object retains enough context for each of the AdRotator’s user defined properties to be able to generate Ads independently of the page.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s