Click here to Skip to main content
13,147,344 members (29,870 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to perform Auto Sign out on close of Browser in ASP.NET?
Posted 31-Jan-13 17:14pm
Updated 23-Feb-13 7:13am
Raul Iloc 11-Apr-14 11:26am
Did you try my solution?

1 solution

Rate this: bad
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:
function onWindowClosing() { 
            if (window.event.clientX < 0 || window.event.clientY < 0)
                    type: "POST",
                    url: "/Account/OnWindowClosing"
       function onKeydown(evt){ 
            if (evt != undefined && evt.altKey && evt.keyCode==115) //Alt + F4 
                    type: "POST",
                    url: "/Account/OnWindowClosing"
       window.onbeforeunload = onWindowClosing; 
       window.document.onkeydown = onKeydown; 

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.

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 |
Web04 | 2.8.170915.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2017
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