SessionStateUtility.RaiseSessionEnd 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ASP.NET 애플리케이션의 Global.asax 파일에 정의된 Session_OnEnd 이벤트를 실행합니다.
public:
static void RaiseSessionEnd(System::Web::SessionState::IHttpSessionState ^ session, System::Object ^ eventSource, EventArgs ^ eventArgs);
public static void RaiseSessionEnd(System.Web.SessionState.IHttpSessionState session, object eventSource, EventArgs eventArgs);
static member RaiseSessionEnd : System.Web.SessionState.IHttpSessionState * obj * EventArgs -> unit
Public Shared Sub RaiseSessionEnd (session As IHttpSessionState, eventSource As Object, eventArgs As EventArgs)
매개 변수
- session
- IHttpSessionState
IHttpSessionState 종료된 세션의 구현 인스턴스입니다.
- eventSource
- Object
이벤트에 제공할 이벤트 원본 개체입니다 Session_OnEnd .
예제
다음 코드 예제에서는 사용자 지정 세션 상태 모듈에서 ReleaseRequestState 이벤트에 대 한 처리기를 보여줍니다. 세션이 중단된 경우 모듈은 메서드를 사용하여 애플리케이션의 Global.asax 파일에 정의된 RaiseSessionEnd 이벤트를 실행합니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 SessionStateUtility 일부입니다.
//
// Event handler for HttpApplication.ReleaseRequestState
//
private void OnReleaseRequestState(object source, EventArgs args)
{
HttpApplication app = (HttpApplication)source;
HttpContext context = app.Context;
string sessionID;
// Read the session state from the context
HttpSessionStateContainer stateProvider =
(HttpSessionStateContainer)(SessionStateUtility.GetHttpSessionStateFromContext(context));
// If Session.Abandon() was called, remove the session data from the local Hashtable
// and execute the Session_OnEnd event from the Global.asax file.
if (stateProvider.IsAbandoned)
{
try
{
pHashtableLock.AcquireWriterLock(Int32.MaxValue);
sessionID = pSessionIDManager.GetSessionID(context);
pSessionItems.Remove(sessionID);
}
finally
{
pHashtableLock.ReleaseWriterLock();
}
SessionStateUtility.RaiseSessionEnd(stateProvider, this, EventArgs.Empty);
}
SessionStateUtility.RemoveHttpSessionStateFromContext(context);
}
'
' Event handler for HttpApplication.ReleaseRequestState
'
Private Sub OnReleaseRequestState(ByVal [source] As Object, ByVal args As EventArgs)
Dim app As HttpApplication = CType([source], HttpApplication)
Dim context As HttpContext = app.Context
Dim sessionID As String
' Read the session state from the context
Dim stateProvider As HttpSessionStateContainer = _
CType(SessionStateUtility.GetHttpSessionStateFromContext(context), HttpSessionStateContainer)
' If Session.Abandon() was called, remove the session data from the local Hashtable
' and execute the Session_OnEnd event from the Global.asax file.
If stateProvider.IsAbandoned Then
Try
pHashtableLock.AcquireWriterLock(Int32.MaxValue)
sessionID = pSessionIDManager.GetSessionID(context)
pSessionItems.Remove(sessionID)
Finally
pHashtableLock.ReleaseWriterLock()
End Try
SessionStateUtility.RaiseSessionEnd(stateProvider, Me, EventArgs.Empty)
End If
SessionStateUtility.RemoveHttpSessionStateFromContext(context)
End Sub
설명
RaiseSessionEnd 메서드는 세션 상태 모듈에서 ASP.NET 애플리케이션의 Global.asax 파일에 정의된 Session_OnEnd 이벤트를 실행하는 데 사용됩니다. 세션 상태 모듈은 세션이 RaiseSessionEnd 중단되거나 세션이 만료되는 경우 메서드를 호출합니다.