简体   繁体   English

导航到其他页面/门户时如何/在何处存储页码

[英]how/where to store the page numbers when navigating to other page / portal

I'm using an usercontrol (*.ascx) in a CMS system C#.NET 我在CMS系统C#.NET中使用用户控件(* .ascx)

I've got a Gridview which displays address. 我有一个显示地址的Gridview。 You hav a link on the line items and you can click on the items (link) which navigates to other page with querystring info and displays the detail information. 您在订单项上拥有一个链接,然后可以单击项目(链接),该项目会导航到带有查询字符串信息的其他页面并显示详细信息。 When the user clicks on cancel/back it returns the the overview page. 当用户单击“取消/返回”时,它将返回概述页面。 Both are separate programs. 两者都是单独的程序。

When the user clicks on Next, Next, Next eg page 7 is displayed. 当用户单击“下一步”,“下一步”,“下一步”时,例如,显示第7页。 So clicking on an "adres link" on Page 7 will open a new page and when the user comes back it should display page 7 back again. 因此,单击页面7上的“广告链接”将打开一个新页面,当用户返回时,它应该再次显示页面7。

I was keeping the page numbers in a session. 我在一个会话中保留页码。 so when the user comes back it reads the pagenumber from the session. 因此,当用户回来时,它会从会话中读取页码。 This works fine. 这很好。 But the issue is this module is used other placess too, and also in other portals (which uses the same module) 但问题在于此模块也用于其他地方,也用于其他门户网站(使用相同的模块)

So when have clicked next next etc and you are on page 7 and then you open another portal or other Porgram which have the same module, it displays page 7. Because it reads the Session variable and sometiems it gives a dump because page 7 doesn't exist, because no much records. 因此,当单击“ Next next”等时,您在第7页上,然后打开另一个具有相同模块的门户网站或其他Porgram,它将显示第7页。因为它读取Session变量和某些内容,所以会转储,因为第7页没有。存在,因为没有太多记录。

Viewstate fix this issue, but everytime after clicking the adres item and coming back it displays page 1, which is not what I want. Viewstate可以解决此问题,但是每次单击adres项目并返回后,它都会显示第1页,这不是我想要的。

As I said, I use the same module in other pages and other portals (same program with different settings CMS -system)... So where and how do I need to store the pagenumbers so it doesn't have conflict with other pages and other portals? 就像我说的,我在其他页面和其他门户中使用相同的模块(同一程序,但CMS -system的设置不同)...所以我需要在哪里以及如何存储页码,以免与其他页面和其他门户?

ViewState["page"] = 7 -> starts on page 1 always when you come back ViewState [“ page”] = 7->每当您回来时,总是从第1页开始

Session["page"] = 7 -> page number is shared.... Session [“ page”] = 7->页码已共享。

Why don't you keep a Structure or Dictionary instead of simple int in the session. 为什么不在会话中保留结构或字典而不是简单的int。 In this you can store Page as well as the Module. 在此您可以存储页面以及模块。

I believe you need to think about instantiation. 我相信您需要考虑实例化。 It seems that you need to isolate each instance of your CMS so each one will share its own set of server variables, includinig session ones. 似乎您需要隔离CMS的每个实例,以便每个实例将共享自己的一组服务器变量,包括会话变量。

Well, it's true you're using some ASCX control, but you can have some "application identifier" so any of control instances can have their own set of values. 好的,您使用的是ASCX控件,但是您可以拥有一些“应用程序标识符”,因此任何控件实例都可以拥有自己的一组值。

Anyway, storing long objects in session is a bad practice, since other modes than "in process" will serialize objects and deserialize them whenever you access to session's state. 无论如何,将长对象存储在会话中是一种不好的做法,因为只要您访问会话状态,除“进行中”模式以外的其他模式都会序列化对象并反序列化它们。

Maybe you need some kind of custom session management in order to optimize performance and memory usage so your components will be rightly isolated and they will remain performant. 也许您需要某种自定义会话管理,以优化性能和内存使用,因此您的组件将被正确隔离并保持性能。

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

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