【问题标题】:ASP.NET Session_End: Determine source of eventASP.NET Session_End:确定事件源
【发布时间】:2017-03-21 23:19:36
【问题描述】:

是否有机会检测到会话超时后是否已调用 Session_End 方法在 web.config 中设置的超时时间或 IIS 本身是否在终止会话后调用设置的应用程序池超时?

【问题讨论】:

    标签: asp.net iis


    【解决方案1】:

    您可以使用 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.
    }
    

    【讨论】:

    • ...并且使用 sender 或 eventargs 参数没有机会获得“实际”来源?
    • 您打算如何处理 sender 和 eventargs?我只是好奇。
    • 如果进程因 AppPool Idle 关闭而终止,基本上我必须在此事件处理程序中运行其他逻辑。 (如果可能的话)
    • 对于应用程序池因空闲而回收或卸载的应用程序,您可能需要使用 Application_End 事件。
    • 谢谢。这是一个非常有价值的提示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-05
    • 2014-05-22
    相关资源
    最近更新 更多