[英]Reset Session on redirect to another page
我正在開發合同管理Web應用程序。 我想在用戶更改頁面時清除所有會話變量。 例如,假設用戶的當前頁面是“ Default.aspx”,並且當用戶將頁面更改為“ Profile.aspx”時,我在此頁面上創建了3個會話變量,應刪除3個會話變量。
請注意:我正在使用ASP.NET。
在Profile.aspx的Page_Load中嘗試類似的操作:
if (!IsPostBack)
{
Session.Clear();
}
嘗試
Session.RemoveAll (); //Removes all session variables. Just calls the Session.Clear() method in its implementation, so for ease you can say there is no difference.
要么
Session.Abandon(); //Releases sessionstate itself to be garbage collected when chance arrives. Only point to note that it happens just before the current request is fulfilled.
要么
Session.Clear(); //Releases all key value pairs immideatly and make them available for garbage collection. But the Resource used by SessionState Collection are intact and booked as is.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.