Configure OutputCache for ASCX from web.config's cache profiles
To configure aspx pages' OutputCache from one place, there is a great tool which is the CacheProfile attribute in <%@ OutputCache %> associated with a custom cache profile defined in the web.config :
<开发者_高级运维;caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="myProfile" duration="300" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
And the line :
<%@ OutputCache CacheProfile="myProfile" VaryByParam="None" %>
does the job. But how to do the same thing for ascx user controls ? CacheProfile isn't in <%@ OutputCache %> :S Is there a workaround ? Thanks.
From http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx :
"Either this attribute (VaryByParam) or the VaryByControl attribute is required when you use the @ OutputCache directive on ASP.NET pages and user controls. A parser error occurs if you fail to include it."
精彩评论