Export (0) Print
Expand All

IHttpSessionState.Abandon Method

Ends the current session.

Namespace:  System.Web.SessionState
Assembly:  System.Web (in System.Web.dll)

void Abandon()

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.

The following code example implements the Abandon method of the IHttpSessionState interface. The 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. 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; }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft