Founder's blog - please Subscribe RSS - Founder's blog if you like this post - About

ASP.NET: mixing OutputCache with Server.Transfer

Mar 26 2009
If there's any ASP.NET developers reading this blog, here's a small tip for you guys.

If you want to optimize your page performance by using the "@OutputCache" directive you might notice that the caching does not work when you perform a "Server.Transfer" operation to that "cached" page.

It's a really long story why this happens... But to work that out just replace the "Server.Transfer" calls with the "Server.Execute" calls. Important: remember to pass the "Response.Output" to this method (NOT some custom text-writer, exactly "Response.Output"):


//this does not work
Server.Transfer("MyCachedPage.aspx");

//this works. Note the "Response.Output"
Server.Execute("MyCachedPage.aspx", Response.Output);



Back to the blog or Subscribe RSS - Founder's blog if you liked the article


comments powered by Disqus