简体   繁体   English

Session_End 事件未触发

[英]Session_End event is not firing

I'm trying to call a method which updates a row in a database table in my Session_End method.我正在尝试调用一个方法,该方法在我的Session_End方法中更新数据库表中的一行。 I've enabled session state in web.config in this way:我以这种方式在 web.config 中启用了 session state :

<sessionState mode="InProc" cookieless="false" timeout="1"/> 

I've run this and did nothing for more for a minute, but I don't see anything getting updated in the table, hence the Session_End method not getting fired.我已经运行了这个,一分钟内什么也没做,但我没有看到表中的任何内容得到更新,因此Session_End方法没有被触发。 Any ideas what I could do or why is it not firing?有什么想法我能做什么,或者为什么没有触发?

Here's some sample code这是一些示例代码

protected void Session_End() 
{
    loguseractivity("logout",userip,serverip);
}

If you do not save anything in the session the Session_End event will not fire.如果您没有在 session 中保存任何内容,则不会触发 Session_End 事件。 There must be something saved in the session atleast once for the Session_End event to fire session 中必须至少保存一次,才能触发 Session_End 事件

So in Session start below I am saving Hello in the Session_Start所以在 Session 下面开始我在 Session_Start 中保存 Hello

protected void Session_Start(object sender, EventArgs e)
{
     Session["Movies"] = "Hello";
}

So after session gets over, the session end event will fire因此,在 session 结束后,将触发 session 结束事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM