Session.Abandon() 不会立即放弃会话
在我的 ASP.NET Web 应用程序中,我在 Page_Load()
中调用 Session.Abandon()
。我希望这会立即放弃会话,并且下次我引用 HttpContext.Current.Session 时应该创建一个新会话。但是,在 Global.asax 中的 Session_End
和 Session_Start
处理程序上放置断点表明,在页面完成呈现之前不会调用这些处理程序。
所以有两个问题:
1)为什么?
2)一旦调用 Session.Abandon() ,如何在页面生命周期内继续使用 HttpContext.Current.Session 。
提前致谢!
In my ASP.NET web app I call Session.Abandon()
in Page_Load()
. I would expect this would abandon the session straight away and the next time I reference the HttpContext.Current.Session
a new session should be created. However, putting breakpoints on the Session_End
and Session_Start
handlers in Global.asax indicates that these aren't called until the page has finished rendering.
So two questions:
1) Why?
2) How can I continue to use HttpContext.Current.Session
within a page lifecycle once Session.Abandon() has been called.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://msdn.microsoft.com/en- us/library/ms524310(v=vs.90).aspx
查看链接页面上的备注部分。
看起来会话对象只是排队等待删除,直到代码运行完毕才被删除。
http://msdn.microsoft.com/en-us/library/ms524310(v=vs.90).aspx
Look at the remarks section on the linked page.
Looks like the session objects are only queued for deletion, and not deleted until the code finishes running.
这是我的解决方案:
这实际上是轨道轰炸选项。
一些信息来源于: http://www.dotnetfunda.com/articles/article1395-how-to-avoid-the-session-fixation-vulnerability-in-aspnet-.aspx
This was my solution:
This is effectively the orbital bombardment option.
Some information sourced from: http://www.dotnetfunda.com/articles/article1395-how-to-avoid-the-session-fixation-vulnerability-in-aspnet-.aspx
Session.Abandon() 实际上会等待页面呈现。
Session.Abandon() actually waits until the page has been rendered.