Click here to Skip to main content
11,501,968 members (64,698 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Javascript

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%">;

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

1 solution

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

Solution 1

var btn = document.getelementByid("<%LogoutButton%">;
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.
mahen25 at 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)

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 24 Mar 2011
Copyright © CodeProject, 1999-2015
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