tags:

views:

165

answers:

10

I have an ASP.net page which has fields for filtering a dataset. When I apply the filter (through a button), the results load fine. If I navigate to another page (on the same session), and then come back to the page, I'm re-setting the value of the filter fields on page load.

Sometimes, the fields will reset fine, sometimes they will come back blank. There doesn't seem to be any real pattern as to when they come back ok and when they come back blank. Is there a possibility that the request/response is being cached by the server? (IIS), if not, then what could be the problem?

Thanks

+2  A: 

Sounds to me more like it's being cached by the browser. Try including no-cache metas in the HTML of the page.

Traveling Tech Guy
Using firebug, it says that the response is 0KB from cache, so no, the browser is not caching them.
ferrari fan
Try Ctrl + Refresh. Perhaps there is an upstream proxy you don't know about?
Gregory
Tried that, the randomness is still there
ferrari fan
are you using Ajax at all? If so, you need to randomize your Ajax calls - there's a well documented IE caching bug
Traveling Tech Guy
This is not particular to IE, and no it's not using AJAX
ferrari fan
A: 
  1. try clear browser chache
  2. iisreset -stop then iisreset -start to restart iis.
loviji
A: 

So what do you mean by re-setting fields ? You store values in session and then on load setting search values from session ?

evilek
+7  A: 

I agree with others that this is a cache problem. If you aren't sending the appropriate headers, then the browser will cache your page. If for example you use the browser's Back button to return to your page, then this will be loaded by the cache and not from the server.

In order to verify this place a breakpoint in the Page_Load method and wait for it to be hit. In order to disable caching you need to do something like this:

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Add(new TimeSpan(-1,0,0));
Response.Expires = 0;
Response.CacheControl = "no-cache";
kgiannakakis
Not using the back button, all navigation is done with links.
ferrari fan
The same things apply also with links. Please try to debug the application and see when actually the Page_Load method is called.
kgiannakakis
+1  A: 

How are you going back to the initial page, via the Back button or by clicking a link to go back to it? When using the Back button the server side code doesn't always run unless you remove the caching on the page.

Shawn Steward
I don't actually have to navigate away from the page. There's a navigation bar on the application, if I re-click the same page in which I'm on that's when the behavior happens.
ferrari fan
+1  A: 

If you are not using Ajax (and thus, the browser doesn't have anything to do with retrieving the data), it does seem that it is either due to cache, or an error in the way you are loading your data.

As a first test, I would add a simple to the page, and write the date and time to it on the Page_Load method. If it works, you can definitely disregard the cache as the origin of the problem.

Now, if it's a problem in the code, do you depend on cookies (session variables) an URL parameter, or any other info that can change while using the app?

salgiza
yes, the values are stored in session variables. I believe that this is a code issue while resetting the values. The application works under a "portal" environment, and the variables are being handled manually.
ferrari fan
A: 

Is it possible that an exception is being thrown before or while the code that populates the field values is being run?

Stuntbeaver
A: 

A fairly quick way to tell what's going on is to throw some breakpoints in there on the lines where you're retrieving the stuff from session and troubleshoot the hell out of it.

If it happens after you've seen the stuff from session being pulled out alright and no other funny business is going on (such as tasty exceptions being swallowed somewhere along the line) then it means it's a browser caching problem (and good luck with that!).

JohnIdol
A: 

The ViewState is being cached somehow. If it's not your browser, then are you connecting through a proxy server that performs some caching.
Also are you sure you're not using something other than InProc for session state?

adamcodes
A: 

Try passing your 'filter' between your pages via the querystring.

This would be a good way to prove (one way or the other) that the problem lies with cache/state and you can see whats actually being passed

Matt Joslin