0

my scenario is this; the user selects the list of reports they wish to print, once they select and click on the a button, i open up another page with the selected reports ready for printing. I am using a session variable to pass reports from one page to another.

first time you try it, it works fine, second time you try it, it opens the report window with the previous selected reports. I have to refresh the page to make sure it loads the latest selections.

is there a way to get the latest value from the session every time you use it? or is there a better way to solve this problem. open for suggestions...

Thanks

C# Asp.net, IE&7 /IE 8

5
  • 2
    This sounds like a problem I had earlier this month, where the browser was returning the cached page. In my case there was a setting in IE that was set to not automatically check for newer content. Aug 11, 2011 at 2:39
  • unfortunately I am unable to change settings on the user's browser setting.
    – AJ17
    Aug 11, 2011 at 3:28
  • When the second page opens and reads the session variables into a local object (I assume you are instead of directly using the session) would you not destroy the session variable then on the second page as you are done using it for this instance? I'm assuming you re-write the latest selection to the session each time before displaying the second page so it will never not exist when the second page reads and destroys it.
    – Nope
    Aug 11, 2011 at 9:30
  • yes i do re-write the session for every new selection...but i cannot destroy the session, cause i need it when i refresh the page also the user can open multiple instance of the second page, depending on the selection he makes on the first page.....
    – AJ17
    Aug 11, 2011 at 12:52
  • i did come up with a solution. using JS i keep a track on the second page from the first page. if the second page is already opened, i refresh the page or else i open it. works OK but not all the time.but this wont work with IE7 at all, only works with IE 8..... any more suggestions?
    – AJ17
    Aug 12, 2011 at 6:14

3 Answers 3

1

After doing some more checking maybe if you check out COMET it might help. The idea is that you can have code in your second page which will keep checking the server for updated values every few seconds and if it finds updated values it will refresh itself.

There are 2 very good links explaining the imlementation.

The first link explains what COMET is and how it ties in with ASP.NET, the second link has an example using a chat room. However, I'm sure the code querying for updates will be pretty generic and can be applied to your scenario.

I have never implemented COMET yet so I'm not sure how complex it is or if it is easy to implement into your solution.

Maybe someone developing the SO application is able to resolve this issue for you. SO uses some real-time feature for the notifications on a page, i.e: You are in the middle of writing an answer and a message pops up in your client letting you know someone else has added an answer and to click "here" to refresh.

1
  • thanks for your help. restricted with time to try this .will look in to this later on. cheers
    – AJ17
    Aug 15, 2011 at 2:05
0

The proper fix is to set the caching directives on the HTTP response correctly, so that the cached response is not reused without validation from the server.

When you fail to specify the cache lifetime, the client has to "guess" how long the response is good for, and the browser's guess probably isn't what you want. See http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

1
  • i used the following code in my Page_PreInt event, still make no difference. unless i am doing something wrong code HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(false); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoStore(); Response.Cache.SetExpires(DateTime.Now); Response.Cache.SetValidUntilExpires(true);
    – AJ17
    Aug 13, 2011 at 6:20
0

It's better to use URL paramaters. So you have a view of value of the paramaters.

1
  • Though Url strings have no maximum length the browsers do have a limitation on the maximum number of characters. Internet Explorer does not support URLs that have more than 2083 characters for example. 2083 characters might be enough but might no be as it is not very clear from the post what data is stored in the session per report. Just something to keep in mind.
    – Nope
    Aug 11, 2011 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.