2008-07-01
Global.asax中的Session_End不能用Context
遇到一个问题:Web.Config中设置的Sestion timeout不起作用,设置的timeout时间到期后,Global.asax中的Session_End能够被调用,但在此事件处理函数中,Context总是为null,这样就没有办法利用Context退出登录。
原因如下:
The Session_End event fires when the browser isn't connected to the server -- so there really isn't anyway to clear out the authentication ticket (since that is stored on the client).
What I'd recommend doing instead is changing the timeout duration of the forms-authentication ticket to be 15 minutes. That way you can avoid having to add a session_end event at all -- and just rely on the browser cookie timing out to force another login.
Q: Do I have a valid HttpContext in Session_End?
A: No, because this event is not associated with any request.
推荐用forms-authentication timeout,在Web.Config中配置如下:
原因如下:
引用
The Session_End event fires when the browser isn't connected to the server -- so there really isn't anyway to clear out the authentication ticket (since that is stored on the client).
What I'd recommend doing instead is changing the timeout duration of the forms-authentication ticket to be 15 minutes. That way you can avoid having to add a session_end event at all -- and just rely on the browser cookie timing out to force another login.
Q: Do I have a valid HttpContext in Session_End?
A: No, because this event is not associated with any request.
推荐用forms-authentication timeout,在Web.Config中配置如下:
<system.web>
<authentication mode="Forms">
<forms timeout="50000000"/>
</authentication>
</system.web>
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 8061 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
链接
最新评论
-
同样的温度,为什么身体的 ...
rtdb 写道我相信心里暗示会有一定的作用, 但是,仍然要符合物理规律,就是说 ...
-- by bo_83 -
同样的温度,为什么身体的 ...
邪恶一下 “老婆,同样的温度,为什么身体的感觉不一样?”
-- by t0uch -
同样的温度,为什么身体的 ...
bo_83 写道someone 写道乖乖,意念都能制冷,夏天都不用买空调了。 呵 ...
-- by rtdb -
同样的温度,为什么身体的 ...
someone 写道乖乖,意念都能制冷,夏天都不用买空调了。 呵呵 同学有点抬杠 ...
-- by bo_83 -
同样的温度,为什么身体的 ...
看了大家的讨论,对这个问题的理解又深入了一步。 但各位请注意, 第一、温度计没有 ...
-- by sunnymelon






评论排行榜