views:

771

answers:

2

Hey all,

I'm hoping someone has seen this before because I can't for the life of me find the problem.

I'm trying to do the old "fix the back button" thing in an application and I think i have a pretty decent approach, the problem is that it relies on the application not calling page_load when you hit back and instead loading the cached version of the page.

On about 60% of my pages that's exactly what happens. It loads the cached version and all is well. On the other 40% when i hit the back button page_load calls, forcing a refresh. For reference the call to page_load is NOT in a postback.

Even stranger is that this only occurs in IE (6 & 7). In firefox page_load never gets called.

I am using ASP.NET Ajax framework on both types of pages. Anyone seen anything like this before?

--Update--

After investigating a bit more I'm finding out that when i use the search to navigate from one page to another the application behaves differently for different pages. On the broken pages the page_load gets called twice, the search gets called twice and in fiddler that turns into 2 different redirect postbacks the second of which has no-cache set.

On the working page page_load and search only happen once and it immediately redirects.

That second Response.Redirect is causing the issue. Still not sure why that's happening though.

A: 

if you are using ASP.NET AJAX why not using the History server control object?

replacing History, the back button will go to the link you want.

try this

balexandre
Id like to but unless im mistaken I'd have to put that on either every page in the app or in the master page. I cant put it n the master page because the scriptmanager tag is on the subpages. Therefore id have to change every page and thats too risky for an in-production application.
JoshReedSchramm
+1  A: 

Check what the server is returning for the cache-control http header, then try setting Response.Cache.SetCacheability()/ use the output cache page directive on the pages and see if the server is saying that the pages should be cached.

Sijin
just pulled down fiddler and checked. For both the pages that are refreshing and the ones that arent cache-control is set to private.
JoshReedSchramm
Found something interesting. I think its the search causing it. The page returns no-cache following a search but not following a normal load.
JoshReedSchramm