当会话进入另一个页面时清除会话 [英] clear the session when it goes to another page
本文介绍了当会话进入另一个页面时清除会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据输入页面和同一页面我将所有控件绑定到与修改页面相同的页面。
i应清除当页面导航到其他页面时的会话。
但我应该在哪个页面事件中我不知道。
I have one page which is of data entery and the same page i m binding it all the controls and making the same page as modify page.
i should clear the session when the page is navigating to other page.
But in which page event i should it i dont know.
推荐答案
你应该做什么它在Page_Load事件中,但仅在页面没有回传时,如下例所示:
You should do it in Page_Load event but only only if the page was not post back like in the next example:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//clear your params from sesssion here!
Session["param1"]= null;
Session["param2"]= null;
//...
}
//....
}
查看要求。
如果要清除特定会话数据
然后执行以下操作
Session [UserData] = null;
如果你想从整个应用程序中清除会话数据,请执行以上操作
会话.Abandon();
你可以使用Session.Clear();或Session.Abandon();
You can Use Session.Clear(); or Session.Abandon();
这篇关于当会话进入另一个页面时清除会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文