简体   繁体   English

浏览器的后退按钮在 ASP.NET 应用程序中随机禁用

[英]Browser's back button disables randomly in ASP.NET application

On my two-page web application, users progressively enter info and make selections on page one.在我的两页 web 应用程序中,用户逐步输入信息并在第一页进行选择。 When done, they click a 'Generate' button that navigates to page two.完成后,他们单击导航到第二页的“生成”按钮。 Users print that page and hit the browser's Back arrow to return to page one with selections intact.用户打印该页面并点击浏览器的后退箭头以返回到第一页,并且选择完好无损。

After a few generated pages (2 or 3), clicking Back just disables the icon without going back.在生成了几个页面(2 或 3 个)之后,单击Back只会禁用图标而不返回。 They have to manually revisit page one, reentering their info and selections.他们必须手动重新访问第一页,重新输入他们的信息和选择。

I found that the down arrow to the right of to the Back / Forward arrows (IE8) that shows the immediate history generally includes all 'previous' pages.我发现显示当前历史记录的后退/前进箭头 (IE8) 右侧的向下箭头通常包括所有“上一个”页面。 But when the back button is about to disable on click, the history only shows the current site.但是当点击后退按钮即将禁用时,历史记录只显示当前站点。

What events, scripts, headers, etc. clear the history for the current site?哪些事件、脚本、标题等清除了当前站点的历史记录? It occurs in IE7 and IE8 on WinXP and Win7.它出现在 WinXP 和 Win7 上的 IE7 和 IE8 中。 In FireFox, the button did not disable, but it did not do anything either.在 FireFox 中,按钮没有禁用,但它也没有做任何事情。 Users report it as a recent and I have been making changes to the application, but it only affects the HTML on page two (not scripts, though).用户报告它是最近的,我一直在对应用程序进行更改,但它只影响第二页上的 HTML(虽然不是脚本)。 It's probably a code issue if it's recent, but I'm not sure what to look for when double checking my recent changes.如果它是最近的,可能是代码问题,但我不确定在仔细检查我最近的更改时要寻找什么。

Which version of IE?哪个版本的IE?

Internally, IE maintains a limited amount of data in the travellog (aka back/forward stack).在内部,IE 在旅行日志(又名后退/前进堆栈)中维护有限数量的数据。 ASP.NET pages with huge postback forms often blow this limit, wiping the history stack. ASP.NET 带有巨大回发的页面 forms 经常打破这个限制,抹去历史堆栈。

In IE6 and IE7, if there is a form input field with a value longer than 523,659 characters, when you navigate away from the page, IE may clear the current session's travellog (similar to history), disabling the back and forward buttons.在 IE6 和 IE7 中,如果有一个值超过 523,659 个字符的表单输入字段,当您离开页面时,IE 可能会清除当前会话的旅行日志(类似于历史记录),禁用后退和前进按钮。

I believe the overall Travellog size limit was upped somewhat in IE8, but it's not more than a few megabytes.我相信整体 Travellog 的大小限制在 IE8 中有所提高,但不会超过几兆字节。

As a general rule, if you want your users to navigate back and forth between pages, I would give them links on the page that do the job (without using javascript:back() ) instead of using the browser's navigation.作为一般规则,如果您希望您的用户在页面之间来回导航,我会在页面上为他们提供完成这项工作的链接(不使用javascript:back() )而不是使用浏览器的导航。

What's happening, most likely, is that the postbacks of a single page are sometimes considered pages, sometimes not.最有可能的情况是,单个页面的回发有时被视为页面,有时则不是。 If a user action loads a page that has the same URI and query string, most browsers consider that "the same page" even though EVERYTHING may have changed.如果用户操作加载具有相同 URI 和查询字符串的页面,大多数浏览器会认为“相同的页面”,即使一切都可能发生了变化。 This is usually due to heavy use of MultiViews with the information about the current view kept in ViewState or Session;这通常是由于多视图的大量使用,当前视图的信息保存在 ViewState 或 Session 中; navigating within that page doesn't change the URI being navigated to, so the browser doesn't log each new load as unique.在该页面内导航不会更改导航到的 URI,因此浏览器不会将每个新加载记录为唯一的。

If you really need proper back-and-forth functionality, you will need to make sure that every link will result in the browser being told to navigate to a different URI than the current page.如果您确实需要适当的来回功能,则需要确保每个链接都会导致浏览器被告知导航到与当前页面不同的 URI。 You can do this by adding a query string element that will be present in every link to a different page or view, that will auto-increment with each click the user takes.您可以通过添加一个查询字符串元素来做到这一点,该元素将出现在指向不同页面或视图的每个链接中,该元素将随着用户每次单击而自动递增。 This gives the browser a different URI every time.这每次都会为浏览器提供不同的 URI。 You only use the existing QueryString element to create the new one on your links' URIs.您只使用现有的 QueryString 元素在链接的 URI 上创建新元素。 This can get cumbersome, and the easier solution is simply to provide in-page navigation and tell your users not to hit "Back" any more.这可能会变得很麻烦,更简单的解决方案是提供页面内导航并告诉您的用户不要再点击“返回”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM