Back Button gets Disabled on IE 7,8 for an ASP.NET

2020-07-24 06:47发布

问题:

In an ASP.NET 3.5 website we are noticing that the back button is not working properly. If the user does several postbacks (say 10 times), and than starts pressing back button - the back button gets disabled before the user gets through all the pages. The site does not use AJAX.net.

I can reproduce the issue on IE 7 and 8 almost always. The problem seems to be with some sort of limit IE has on History Cache for a given tab/instance. In the tests I did the post request to the server are large - around 83k, and the responses are are round 300k. It seems that with these request sizes the history does not hold more than 4 items. The moment I get to the 5 post, the first item i had selected is dropped.

回答1:

We experienced the same issue. We would load a particular page, and after about 5 seconds, IE8 browser history would get blown away. As a result, history.back() would not work, and IE8 back button would not work. Eventually, we narrowed it down to the large "viewstate" (In our case, the size of the "viewstate" was like 600KB due to "Repeater" control having "viewstate" enabled). When we disabled the "viewstate" on the "Repeater" control, the size came down to about 11KB. Now, both IE8 back button and history.back() work well.



回答2:

The user has to have gone back to the first page; that's the only way I know of to disable the back button in IE (or any other browser). Did the application open another tab; that could cause confusion on how far the back button will go.

Also, is the user getting prompted, by IE, to reapply changes when they hit the back button? I know that is an issue with ASP.NET sites in general and that could cause problems in the browser with using the back button.



回答3:

window.location.replace or

history.forward();

in the head



回答4:

This is a bug in IE that has manifested in one way or another since (at least) IE6. The bug is in the TravelLog code. It sometimes gets confused.