简体   繁体   English

ASP.NET缓存查询

[英]Asp.net cache query

I currently have an asp.net website that stores all the viewstate on the server side. 我目前有一个asp.net网站,它将所有viewstate存储在服务器端。 I have come across one issue. 我遇到了一个问题。 I have a landing page that lists a number of stats in a gridview, each row having a "view" button which goes to a page containing a detailed list of the selected stat. 我有一个登录页面,该页面在gridview中列出了许多统计信息,每行都有一个“视图”按钮,该按钮转到包含所选统计信息的详细列表的页面。

If the user uses their back button to get back to the main list and repeat the process of pressing the "view" button after 10 repeats the initial landing page loses all state. 如果用户使用其后退按钮返回到主列表,并在10次重复后重复按“查看”按钮的过程,则初始登录页面将失去所有状态。 I have got round this by setting the <sessionPageState historySize="40"> in the web config which allows the above process to be repeated 40 times until the initial landing page loses all state and needs fully reloading. 通过在Web配置中设置<sessionPageState historySize="40"> ,可以使上述过程重复40次,直到初始登录页面失去所有状态并需要完全重新加载为止。

Now this fixes the issue here but obviously has an issue on other pages by leading to a large sessionstate when users use the rest of the site. 现在,这可以解决此问题,但显然在其他页面上存在问题,因为当用户使用网站的其余部分时,会导致会话状态变大。 What is the best method to get round this? 解决这个问题的最佳方法是什么?

Thanks 谢谢

View State is designed for storing the state of objects on the page being loaded. View State旨在存储要加载的页面上对象的状态。 It isn't stored server side and is a collection of the page's controls and their values in a Base 64 encoded string sent out with the page. 它不是存储在服务器端的,而是与页面一起发送的以Base 64编码的字符串形式存储的页面控件及其值的集合。

For passing data between pages you should look at Session which will persist for as long as the user is active (until Session expires or you manually kill it). 为了在页面之间传递数据,您应该查看会话 ,该会话将一直持续到用户处于活动状态为止(直到会话过期或您手动将其杀死)。

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

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