表单身份验证超时日志记录
我想检测 asp.net 表单身份验证票证何时过期。然后,我想将因不活动而注销的用户登录到服务器。当身份验证票证过期时,服务器上是否会触发一个事件?
<sessionState mode="InProc" timeout="5"></sessionState>
<authentication mode="Forms">
<forms loginUrl="~/Home/AccessDenied" timeout="5" />
</authentication>
在全局asax文件中,我尝试了Session_OnEnd()。但 context.user 对象为空。当我调用membership.getuser()时,它也返回null。我尝试在身份验证之前使会话超时,但这没有帮助。我使用的是mvc3和ii7.5。
I want to detect when a asp.net Form Authentication ticket has expired. I then want to log to the server the user that was signed out because of inactivity. Is there an event that fires on the server when the authentication ticket has expired?
<sessionState mode="InProc" timeout="5"></sessionState>
<authentication mode="Forms">
<forms loginUrl="~/Home/AccessDenied" timeout="5" />
</authentication>
In the global asax file, I have tried the Session_OnEnd(). But the context.user object is null. When i call membership.getuser() it returns null also. I have tried making the session timeout before the auth but that doesn't help. I am using mvc3 and ii7.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
会话和表单身份验证有两个完全独立的超时。
请参阅我在此处发布的帖子:
我该怎么办处理 ASP.NET 中的表单身份验证超时异常?
在 Application_PreRequestHandlerExecute 中,您需要检查票证。
另外,请使用我在那里发布的代码确保您的会话和表单身份验证超时是同步的。不只是将两者都设置为 60 分钟。由于表单身份验证直到一半的时间过去后才会更新“触摸”时间,并且会话时间会根据每个请求进行更新,因此它们不同步。
Session and forms authentication have two completely separate timeouts.
See my posting on this here:
How can I handle forms authentication timeout exceptions in ASP.NET?
In Application_PreRequestHandlerExecute you need to check the ticket.
Also be sure your session and forms auth timeouts are in sync using the code I posted there. Not just setting both to say 60 minutes. Since forms auth doesn't update the 'touched' time until half of the time passes by, and session time is updated on every request, they get out of sync.