通用返回功能
我需要在我的项目中实现后退功能,为此我正在做的就是在 ViewData["RetUrl"] 中维护最后一个 url,并在下一页上我从该 ViewData["RetUrl"] 获取上一个 url。我已经实现了这个功能。当页面级别增加时,这个想法失败了,我的意思是第1页>第2页>第3页,无法将第3页返回到第1页。我只能维持1个级别。
现在我正在考虑一种通用的实现方式,我可以在下一个项目中轻松实现它。请帮助我提出您的想法...
我正在研究 ASP.NET MVC。
I need to implement back functionality in my project, for this what i am doing that i am maintain last url in ViewData["RetUrl"] and on next page i am getting previous url from that ViewData["RetUrl"].on this way i had implemented this functionality.This idea is failed when level of pages increased i mean page1>page2>page3, no way to back page3 to page1.i can aonly able to maintain 1 level.
Now i am thinking for a generic kind of implementation which i can easily implement on my next project.Please help me with your idea about this...
I am working on ASP.NET MVC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您还记得并非所有页面请求都是 GET 位,并且包含一些 POST 和可能的其他动词,那么事情也会变得复杂。
我曾经想做类似的事情,但后来放弃了这个想法。其实并不是那么需要。作为如何解决问题的想法......
在每个请求中,将当前页面和动词成对记录在一起,例如:
您可以将此信息存储在 TempData 集合中,在每个请求时读取它,并通过添加当前请求详细信息来更新它。然后,您实现一些框架方法,该方法将扫描集合,跳过所有 POST(或您需要的任何内容),并为您提供之前的 GET url。
It also gets complicated if you recall that not all page requests are GET bit include some POST and possibly other verbs.
I once wanted to do something similar but then abandoned the idea. It's not really that needed. As an idea on how to approach the problem...
At each request record the current page and the verb together in pair like:
You can store this information in the TempData collection, read it at each request and update it by adding current request details. Then you implement some framework method that will scan the collection skipping all POSTs (or whatever you need) and give you the previous GET url.