IHttpSessionState.Abandon 方法

定义

结束当前会话。Ends the current session.

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

示例

下面的代码示例实现了 Abandon 接口的方法 IHttpSessionStateThe following code example implements the Abandon method of the IHttpSessionState interface. 此代码示例复制类的行为 HttpSessionStateContainer ,因为它添加了一个在 IsAbandoned true 调用方法时设置为的属性 AbandonThe code example duplicates the behavior of the HttpSessionStateContainer class in that it adds an IsAbandoned property that is set to true when the Abandon method is called. IsAbandoned 事件发生时,会话状态模块会检查属性 ReleaseRequestState ,以确定会话是否已被放弃,并且会话状态模块会清除会话数据并执行 Session_OnEnd 事件。The IsAbandoned property is checked by the session-state module during the ReleaseRequestState event to determine whether the session has been abandoned, and the session-state module clears out session data and executes the Session_OnEnd event.

//
// 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 事件。The Abandon method is used to clear out session data and raise the Session_OnEnd event defined in the Global.asax file for the ASP.NET application.

适用于