简体   繁体   English

何时清除ViewState会话?

[英]When is ViewState session cleared ?

I know SessionState is Cleared when the session dies - usually after 20min of inactivity. 我知道会话死亡时会清除SessionState-通常在闲置20分钟后。 My question is when does ViewState session dies ? 我的问题是ViewState会话何时死亡? Or does it never dies ? 还是永不消亡? Is there any way to clear it ? 有什么办法清除它吗?

Viewstate lasts for as long as it's on the page - it's outputted with the HTML; Viewstate持续的时间与在页面上一样长-它是与HTML一起输出的; check the source to your rendered page and you will see a load of text in a hidden field. 检查显示页面的源代码,您将在隐藏字段中看到大量文本。

Something like: 就像是:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTIyODQ4NzI.....

Once the page is gone, it's gone. 页面消失后,它也消失了。

You can clear it by calling 您可以通过致电清除它

ViewState.Clear()

Old ViewState, like old soldiers , never dies, it just fades away... 老ViewState就像老兵一样 ,永不消亡,它逐渐消失……

It's stored in hidden fields in the HTML page, and stays alive in the browser's cache. 它存储在HTML页面的隐藏字段中,并在浏览器的缓存中保持活动状态。

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

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