简体   繁体   English

ASP.NET身份验证超时和注销事件

[英]ASP.NET authentication timeout and Logout Events

From my understanding after Googling the issue, the authentication ticket used by ASP.NET for user authentication expires after a set amount of time at which point any postback or page loads will cause the user to be redirected to a login page. 根据对问题进行谷歌搜索后的理解,ASP.NET用于用户身份验证的身份验证票证会在设定的时间段后过期,届时,任何回发或页面加载都将导致用户重定向到登录页面。 However, there is no event that gets triggered when the ticket times out. 但是,票证超时时不会触发任何事件。 Therefore, if I wish to implement a logout event, it won't get triggered when the ticket expires. 因此,如果我希望实现注销事件,则在票证过期时不会触发该事件。

My question is: Is there anyway to circumvent this issue? 我的问题是:是否有任何方法可以规避此问题? I need to log when users log out of my website but if the ticket times out and the user gets redirected to the login page and thinks that they've been logged out so they just close the browser, I will never have a record of when they log out. 当用户退出我的网站时,我需要登录,但是如果票证超时并且用户重定向到登录页面,并认为他们已经注销,那么他们只是关闭浏览器,我将永远不会有什么时间的记录。他们注销。

Thanks 谢谢

I saw this kind of behavior done by putting the custom object to asp.net cache. 通过将自定义对象放入asp.net缓存,我看到了这种行为。 You set the cache timeout to the same time-frame as session and you refresh it every time user comes to the website. 您将缓存超时设置为与会话相同的时间范围,并在用户每次访问网站时刷新它。 When cache timeout method is fired you know that user session ended. 当触发缓存超时方法时,您知道该用户会话已结束。

This is dirty approach though, application can be restarted, user can return, session is ended, but it does not mean that user is logged out. 虽然这是一种肮脏的方法,但是应用程序可以重新启动,用户可以返回,会话结束,但这并不意味着用户已注销。

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

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