IHttpSessionState.Abandon 方法

定義

結束目前的工作階段。

public:
 void Abandon();
public void Abandon ();
abstract member Abandon : unit -> unit
Public Sub Abandon ()

範例

下列程式碼範例會實作 Abandon 介面的 IHttpSessionState 方法。 程式碼範例會複製 類別的行為 HttpSessionStateContainer ,因為它會在呼叫 方法時 Abandon 加入 IsAbandoned 設定為 true 的屬性。 在 IsAbandoned 事件期間 ReleaseRequestState ,會話狀態模組會檢查屬性,以判斷會話是否已放棄,而會話狀態模組會清除會話資料並執行 Session_OnEnd 事件。

//
// Abandon marks the session as abandoned. The IsAbandoned property is used by the
// session state module to perform the abandon work during the ReleaseRequestState event.
//
public void Abandon()
{
  pAbandon = true;
}

public bool IsAbandoned
{
  get { return pAbandon; }
}
'
' Abandon marks the session as abandoned. The IsAbandoned property is used by the
' session state module to perform the abandon work during the ReleaseRequestState event.
'
Public Sub Abandon() Implements IHttpSessionState.Abandon
  pAbandon = True
End Sub

Public ReadOnly Property IsAbandoned As Boolean  
  Get
    Return pAbandon
  End Get
End Property

備註

方法 Abandon 可用來清除會話資料,並引發在 ASP.NET 應用程式之 Global.asax 檔案中定義的 Session_OnEnd 事件。

適用於

另請參閱