automatically logging users out of asp.net website on close

情到浓时终转凉″ 提交于 2019-12-08 06:37:31

问题


I recently inherited an asp.net website made up of multiple .aspx and .ascx pages and being rather new to web development and especailly asp.net. I have the site create a cookie upon login to automatically log users back in if the page times out on them while they're entering information.

I need the site to automatically log users out when the site is closed. Obviously using the me.close event on each page won't work because we don't want it to log people out every time they navigate to a new page in the site.

I've tried setting the timeouts in both IIS and in the files of the website to longer but it doesn't seem to have an effect.

Is there an easy way to automatically log users out when they leave the site but not when they navigate from page to page.


回答1:


HTTP is a stateless protocol, so there really is no easy way to do this.

If it's going to be an essential part of your service, you can use AJAX pings every 30 seconds, then if there isn't a ping for 2 minutes you can log them out.

This is what I've done on one of my sites apps and it seems to work quite well.



来源:https://stackoverflow.com/questions/5354627/automatically-logging-users-out-of-asp-net-website-on-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!