Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
How to perform Auto Sign out on close of Browser in ASP.NET?
Posted 31-Jan-13 18:14pm
Edited 23-Feb-13 8:13am
ProgramFOX127.8K
v2
Comments
Raul Iloc at 11-Apr-14 11:26am
   
Did you try my solution?

1 solution

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

Solution 2

In my main layout (master page) of my ASP.NET MVC site I am ussing the next java script:
<script>
function onWindowClosing() { 
            if (window.event.clientX < 0 || window.event.clientY < 0)
            {
                $.ajax({
                    type: "POST",
                    url: "/Account/OnWindowClosing"
                });
            }
       };
 
       function onKeydown(evt){ 
            if (evt != undefined && evt.altKey && evt.keyCode==115) //Alt + F4 
            { 
                $.ajax({
                    type: "POST",
                    url: "/Account/OnWindowClosing"
                });
            } 
       };
 
       window.onbeforeunload = onWindowClosing; 
       window.document.onkeydown = onKeydown; 
 
    </script>
You should do something similar in your master page.
Then in your source code ("OnWindowClosing" action from "Account" controller in my example) you could do what you want.
  Permalink  
v3

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

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
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