如何让后退按钮和会话状态一起工作?
这个问题可能有一个简单的答案,但我只是看不到它,因为我离这个项目太近了——就这样吧。
我有一个 asp.net 2.0 搜索应用程序。它是一系列页面,以搜索表单开始,以向用户显示的结果结束。在搜索和结果页面之间是一个过滤器页面,它显示一系列过滤器,用户可以将搜索结果过滤到其中。我在搜索页面上执行初始搜索并将结果存储在会话中。如果初始搜索结果总数超过一定数量(为了示例,我们假设为 50),用户将被带到过滤器页面。在那里,他们会看到许多可以应用于结果的过滤器。
将所选过滤器应用于搜索结果后,如果计数仍超过 50,它们将保留在页面上,仅未选择的过滤器仍显示在页面上。如果计数小于 50,它们将被带到结果页面。现在,如果他们在过滤器页面上但希望查看结果,可以使用一个按钮获取结果的当前状态并将用户带到结果页面。
这是我的问题 - 如果我在应用一些过滤器后进入结果页面并单击后退按钮(没有页面缓存),我如何才能在执行任何操作之前获取搜索结果的先前状态我选择的过滤器已应用?更进一步,如果我在一系列 4 个“应用过滤器”之后到达结果页面(应用过滤器 - 仍然超过 50,应用其他过滤器 - 仍然超过 50,应用另一个过滤器 - 仍然超过 50,最后应用另一个过滤器- 是的!低于 50 则转到结果页面),如果我一直按后退按钮,如何从会话中获取不断缩小的搜索结果的每个版本?
抱歉,如果这有点奇怪并且不太容易理解 - 这是不够简单的问题之一,无法用几个简单的句子来概括它。
我最渴望得到任何想法(与手头的问题有关)或问题。
更新- 仅供参考,我没有决定多页设计。一项要求指出,它遵循现有第三方搜索应用程序的流程(逆向工程很棒,对吧?)。
谢谢
There may be an easy answer to this and I just don't see it b/c I am too close to the project - so be it.
I have an asp.net 2.0 search application. It is a series of pages that start with a search form and end with the results being displayed to the user. Between the search and results page is a filter page that displays a series of filters the user can filter down the search results to. I execute the initial search on the search page and store the results in the session. If the initial search results total more than a certain number (let us say 50 for the sake of the example), the user is taken to the filters page. There they are presented with a number of filters they can apply to the results.
Once the selected filters have been applied to the search results, if the count is still more than 50 they stay on the page with only the filters they have not selected still displayed on the page. If the count is less than 50, they are taken to the results page. Now if they are on the filters page but wish to see the results, there is a button that takes the current state of the results and takes the user to the results page.
Here is my problem - if I am on the results page after applying some filters and click on the back button (none of the pages cache), how can i get the previous state of the search results BEFORE whatever filters I selected had been applied? Even further, if I got to the results page after a series of say 4 "apply filters" (apply filter - still over 50, apply other filter - still over 50, apply yet another filter - still over 50, and finally apply another filter - yay! under 50 go to results page), how do I get each version of the ever shrinking search results from the session if I keep hitting the back button?
Sorry if this is a bit weird and not that easy to understand - this is one of the problems that is not simple enough to just wrap it in a few simple sentences.
I am most eager for any thoughts (pertaining to the question at hand) or questions.
UPDATE -
FYI, I did not decide on the mult-page design. A requirement stated that it follow the flow of an existing third-party search app (reverse engineering is wonderful right?).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要太挑剔,但你所描述的听起来像是一种非常夸张的处理搜索的方式。
通常,您的搜索条件和结果位于同一页面上。当您修改条件并单击搜索时,您应该只显示前 50 个结果,并让他们知道还有更多结果。这不会比您所描述的操作更昂贵,因为无论如何您都必须在两种情况下运行查询。
看看 NewEgg.com 并尝试从 此页面。您会注意到左侧大约有 20 个不同的标准因素。当您添加新条件时,页面顶部的面包屑会发生变化。它们在面包屑中的每个旁边都有一个小 (x),因此您可以快速从搜索结果中删除任何条件。瞧,不需要后退按钮。
请注意,您在任何时候都不需要会话状态来处理此问题。最多您可以使用隐藏的表单字段,如果他们真的愿意的话,它们仍然支持浏览器中的后退按钮使用。
Not to be too critical, but what you described sounds like a seriously jacked up way of handling search.
Typically, your search criteria and results are on the same page. When you modify the criteria and click search you should just display the top 50 results and let them know there are more. This can't be any more expensive an operation that what you've described because you have to run the queries under both circumstances anyway.
Take a look at NewEgg.com and try their "advanced search" from this page. You'll notice there are about 20 different criteria factors on the left. As you add a new criteria, the bread crumb at the top of the page changes. They have a little (x) next to each in the bread crumb so you can quickly eliminate any criteria from your search results. Voila no back button needed.
Note that at no point do you need session state to handle this. At most you could use hidden form fields which would still support back button usage in the browser, if they really wanted to.
按原样使用当前基于会话的参数,但让任何查询字符串参数覆盖它们。通过这种方式,您可以保留您的值,而不将它们分配给每个 url,但会调整到任何以前的手动数据输入(浏览器历史记录中的查询字符串)。
(并且不要使用 POST 进行搜索。)
Use your current session-based parameters as is, but let any querystring-parameter override them. This way you keep your values w/o assigning them to every url, yet adjusts to any previous manual data-enrty (querystrings in the browser-history).
(And don't use POST for search.)