Click here to Skip to main content
12,500,915 members (54,284 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
Hi

I have one log out button on the click of it i have called formsauthentication.signout method its works fine but when i closed Browser tab without pressing Logout button user session stays alive. what i want to generate that button event or call formsauthentication.signout method on closing of browser tab via javascript function any suggestions.I know that i have to call that javascript function in bodyUnload. any body help me what i have to write to generate that button even in javascript i have Tried

var btn = document.getelementByid("<%LogoutButton%">
btn.click();

but its not working. any suggestions
Posted 23-Mar-11 19:12pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

var btn = document.getelementByid("<%LogoutButton%">
btn.click();
This does initiate but by the time Click is called, the form is already closed and thus the event is not executed. Thus, it's not working. Try to put a delay such that onclick event can occur and see. Though, I would like to inform, handling browser close is not easy and full proof.

Also, instead of calling click, try to call a XMLHttpRequest and try to signout.

BTW, session and forms authentication - Both are different.
  Permalink  
Comments
mahen25 24-Mar-11 1:45am
   
Thanks sandeep

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 24 Mar 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100