i am using OutputCache on a ASP.NET Page. I set it programmatically like this in my Page_Load:
Response.AddFileDependency(cachefilepath);
Response.Cache.SetExpires(DateTime.Now.AddHours(12));
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetValidUntilExpires(true);
Response.Cache.SetSlidingExpiration(false);
Response.Cache.VaryByParams["*"] = true;
Now the Page will be cached and this works fine. But i have one UserControl on the Page which shouldn't be cached. Is it possbile to disable Caching for this UserControl although the whole Page is getting cached?
The reason is that the output of this UserControl has two states and so can be different for each client according t开发者_如何学Co his actions...
Response.Cache is per Web Page, you will have to manage the cache on the whole page based on the user control, in other words you will have to expire the page cache when your user control is dynamic, looks like in your case page output cache will not work well
or you can add VaryByControl and pass that control, ref: http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx
精彩评论