ASP.NET: mixing OutputCache with Server.Transfer
Mar 26 2009 :: by Alex
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
//this works. Note the "Response.Output"
by Alex. CEO, founder