Mar 26 2009 :: by Alex Yumashev
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"
Server.Execute("MyCachedPage.aspx", Response.Output);

'ASP.NET: mixing OutputCache with Server.Transfer' was written by Alex Yumashev
Alex Yumashev
Alex has founded Jitbit in 2005 and is a software engineer passionate about customer support.

Subscribe comments