logging out of a web application

  • Thread starter Thread starter bthumber
  • Start date Start date
B

bthumber

When the user leaves the web either by using the logout button or navigating
away from the page I'd like to log them out so that they would need to
authenicate again or the next time to visit the site. How do you do that,
and where do I put this code.
 
bthumber said:
When the user leaves the web either by using the logout button or
navigating
away from the page I'd like to log them out so that they would need to
authenicate again or the next time to visit the site. How do you do that,
and where do I put this code.

In the case of the logout button, you can do FormsAuthentication.SignOut()
in the Click event for the button (assuming that you are using ASP.NET Forms
authentication).

However, when the user navigates away from your page, the browser does not
send anything to your server, so there is nothing that you can do in your
asp.net code to detect this situation other than using a timeout, which is
already provided by Forms Authentication. You could attempt some trick by
means of javascript on the client side, but this is something you would need
to ask at a javascript or asp.net forum, it can't be done with C# on the
server.
 
When the user leaves the web either by using the logout button or navigating
away from the page I'd like to log them out so that they would need to
authenicate again or the next time to visit the site.  How do you do that,
and where do I put this code.

Hi,

You can call Session.Abandon().
 
bthumber said:
When the user leaves the web either by using the logout button or navigating
away from the page I'd like to log them out so that they would need to
authenicate again or the next time to visit the site. How do you do that,
and where do I put this code.

You could consider using what is talked about in the link to force logout if
the user moves away from the logged in ASP.Net application.

<http://anubhavg.wordpress.com/2007/12/27/session-not-timing-out-when-browsing-away-from-application/>
 
Back
Top