创建ASP.NET到期会话值 [英] creating expiring ASP.NET session value
本文介绍了创建ASP.NET到期会话值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个在5分钟内到期的会话值。
如何做到这一点,我需要手动比较创建时间,当我读它?
会议(sessionval)= MYVARIABLE
会议(sessioncreated)现在=
解决方案
您不能定义自定义超时会话变量。
也许你可以使用缓存对于这一点,与依赖于会话的唯一密钥。
您可以设置超时为缓存项。
Cache.Insert(key_dependent_to_session,价值,没什么,
DateTime.Now.AddMinutes(5),TimeSpan.Zero)
I like to create a session value that expires in 5 minutes.
How to do that, do I need to manually compare creation time when I read it?
Session("sessionval") = myvariable
Session("sessioncreated") = now
解决方案
you can not define custom timeout to a session variable.
Maybe you can use cache for this, with a unique key dependent to session.
You can set timeout to a cached item.
Cache.Insert("key_dependent_to_session", value, Nothing,
DateTime.Now.AddMinutes(5), TimeSpan.Zero)
这篇关于创建ASP.NET到期会话值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文