Session失效时能否调用方法.

Kinli 2003-03-22 11:20:05
我用SQL数据库做了个在线用户信息的表,其中字段online记录用户是否在线,用户手动退出时用update修改online为false,我已经做到了,但当Session过期时也是调用修改online为false的这个方法,却无法修改数据库.(我用的判定参数是Session["name"]).请问那位可以帮帮我.急用呀!
我的Do_off事件是这样的
{
Login i = new Login();
i.off(Session["name"].ToString());
Session.Abandon();
} //此事件可修改数据库

但在global.asax的Session_End却不行了.
{
Application.Lock();
Login i = new Login();
i.off(Session["name"].ToString();
Application.UnLock();
}
...全文
91 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kinli 2003-03-22
  • 打赏
  • 举报
回复
i set: timeout="1", and i realized call Session.Abandon() to trigger Session_End.

We know, if we wanna count online user , will write Application["sth"]++ or Application["sth"]-- in Session_Start and Session_End.

The Session is timeout ,the Session_End will be trig automatically.

i just wanna know how come my Session_End can not work when session timeout.
saucer 2003-03-22
  • 打赏
  • 举报
回复
oh, normally it will take 20 minutes, it is easier to just call in logout.aspx:
Session.Abandon()

to trigger Session_End
Kinli 2003-03-22
  • 打赏
  • 举报
回复
To Rainightwind(雨夜):
i done that.
Kinli 2003-03-22
  • 打赏
  • 举报
回复
timeout, when the session of user is timeout, i hope it can update the DataBase automatically(call off()).
Rainightwind 2003-03-22
  • 打赏
  • 举报
回复
在globa.asax.cs 里面做

protected void Session_End(Object sender, EventArgs e)
{
//// U code
}
saucer 2003-03-22
  • 打赏
  • 举报
回复
how did you trigger Session_End? calling Session.Abandon()?
Kinli 2003-03-22
  • 打赏
  • 举报
回复
这不算,这只是我打错而已.
贝贝壳壳 2003-03-22
  • 打赏
  • 举报
回复
老大眼忒尖!
saucer 2003-03-22
  • 打赏
  • 举报
回复
should be similar, but


i.off(Session["name"].ToString();

==>

i.off(Session["name"].ToString());
saucer 2003-03-22
  • 打赏
  • 举报
回复
I cannot tell what's wrong

in Session_End, try to output Session["name"] and other messages (like the Message property of any Exception that could be thrown by Login.off() method) to a file to make sure it is being properly called
Kinli 2003-03-22
  • 打赏
  • 举报
回复
and all the setting is correct.
Kinli 2003-03-22
  • 打赏
  • 举报
回复
SQL Server 2000.
saucer 2003-03-22
  • 打赏
  • 举报
回复
it should, what database are you using? if you are using Server.MapPath(...) inside Login.off(), it may fail, try to use absolute path

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧