在ASP.net中清除会话 [英] to clear session in ASP.net

查看:173
本文介绍了在ASP.net中清除会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请在离开页面后尽快释放会话变量使用的所有内存。我正在记忆异常。



谢谢

Sherin

解决方案

有两种方法。请参阅此链接



Session.Abandon()和Session.Clear()之间有什么区别



<大>它声明:



1) Session.clear() - 删除所有键会话状态集合中的值和值。



2) Session.Abandon() - 删除所有对象存储在会话中。如果您没有显式调用Abandon方法,服务器会删除这些对象并在会话超时时销毁会话。它还会引发Session_End等事件。



引用:

可以将Session.Clear与从架子上移除所有书籍进行比较,而Session.Abandon更像是扔掉整个架子。



问候......:笑:


试试这个

Session [Sessionname] =;


Hi,
Please help me to release all of the memory used by session variables very soon after leaving the page. i am getting out of memory exception.

Thanks
Sherin

There are two ways.Refer this link

What is the difference between Session.Abandon() and Session.Clear()

It states that:

1) Session.clear()-Removes all keys and values from the session-state collection.

2) Session.Abandon()-Removes all the objects stored in a Session. If you do not call the Abandon method explicitly, the server removes these objects and destroys the session when the session times out.It also raises events like Session_End.

Quote:

Session.Clear can be compared to removing all books from the shelf, while Session.Abandon is more like throwing away the whole shelf.


Regards..:laugh:


Try this
Session["Sessionname"]="";


这篇关于在ASP.net中清除会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆