Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Signout user in ASP.Net Identity when browser closed ?
Posted
Updated 13-Jan-17 11:05am
Comments
ZurdoDev 4-Nov-15 10:12am    
There is no perfect way to do it so I suggest you don't even bother. However, you can use the onbeforeunload of a window in JS and call a webservice to log them out.
Herman<T>.Instance 5-Nov-15 6:17am    
Set is as answer. We can upvote you then.
John C Rayan 4-Nov-15 10:16am    
RayanDev is spot on.
Patrice T 13-Jan-17 19:56pm    
What is the interest of signout ?

You can't as your website doesn't know if the user has closed the browser.
 
Share this answer
 
As mentioned in the comments, there is no perfect way to do it so I suggest you don't even bother. However, you can use the onbeforeunload event of a window in JS and call a webservice to log them out. But you can't be sure they didn't open your site in another tab of the browser.
 
Share this answer
 
Comments
Vincent Maverick Durano 15-Jan-17 17:04pm    
As you said, there's no guarantee that onbeforeunlaoad will work as this event will also trigger when the user clicks on the hyperlink or attempts to navigate away from other pages.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900