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);

2 comments:
Thanks. Was using Server.Execute for pulling a separate data page on our intranet, and it was not caching properly. Adding the 'Response.Output' did the trick.
This is causing my code-behind to run twice. The second time code-behind executes, the server.transfer i'm using to do url rewriting is not working and the code crashes. :(
Post a Comment