2017-03-21 67 views
0

是否有機會檢測會話超時後web.config中設置的超時是否已調用Session_End方法,或者在終止後IIS本身是否調用它由於設置的應用程序池超時而導致的會話?ASP.NET Session_End:確定事件源

回答

0

您可以使用的Global.asaxSession_End中事件。

Session_End當會話過期或應用程序池按計劃回收時,會自動引發事件。

private void Session_End(object sender, EventArgs e) 
{ 
    // Code that runs when a session ends. 
    // Note: The Session_End event is raised only when the sessionstate mode 
    // is set to InProc in the Web.config file. If session mode is set 
    // to StateServer or SQLServer, the event is not raised. 
} 
+0

...並使用sender或eventargs參數沒有機會得到「實際」的來源? – 0xDECAFBAD

+0

你打算如何處理sender和eventargs?我只是好奇。 – Win

+0

基本上我必須在這個事件處理程序中運行其他邏輯,如果進程被AppPool空閒關閉終止。 (如果它甚至可能) – 0xDECAFBAD

相關問題