tags:

views:

765

answers:

2

I am implementing a web application using ASP .Net and C#. One of the pages has a requirement that it always needs to be fetched from the server, rather than from the local browser cache. I have been able to achieve this.

We have a back button in the application, which simply invokes javascript:history.back() method. The problem is that when the back button is clicked to navigate to the page which is always to be reloaded from the server, the browser displays a "Web page expired message".

The intent here is to force the browser to reload the page rather than display the web page expired message.

Any help would be highly appreciated. Thanks a ton in advance.

+1  A: 

You will probably need to change the implementation to make the browser load the URL explicitly:

window.location.href = 'http://....';

instead of invoking the back button, since the intention of the back button is to get the last page from the cache.

(If browsers would not act that way, they would re-send your form data multiple times when using the back button during a registration process or similar.)

chiccodoro
We have tried the approach of making the browser explicitly load the URL but it gets into an infinite loop.
Ganesh
you need to add the line above as part of a function or call it on an event only. e.g. <input type="button" value="Go Back" onclick="window.location.href='originalPage.html';"/>
scunliffe
A: 

You mean you want to control browser behaviour, which is not possible. I doubt you can solve it that way. You could set the expiration time to a small value (1 minute perhaps?) so that the page is still valid if one navigates back quickly.

soulmerge