Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. To call Session_End when the user closes the browser window??

To call Session_End when the user closes the browser window??

Scheduled Pinned Locked Moved ASP.NET
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahman Mahmoodi
    wrote on last edited by
    #1

    Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void Session_End(Object sender, EventArgs e) when the user closes the browser window? I have a button that user can press logoff and I can abondan the session but if the user closes the window it doesn't fire. possible at all? -- modified at 1:42 Wednesday 14th September, 2005

    G E 2 Replies Last reply
    0
    • R Rahman Mahmoodi

      Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void Session_End(Object sender, EventArgs e) when the user closes the browser window? I have a button that user can press logoff and I can abondan the session but if the user closes the window it doesn't fire. possible at all? -- modified at 1:42 Wednesday 14th September, 2005

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      That is only possible using javascript. In the onunload event, open a new window with a page that does the logoff, and then closes itself. --- b { font-weight: normal; }

      R 1 Reply Last reply
      0
      • R Rahman Mahmoodi

        Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void Session_End(Object sender, EventArgs e) when the user closes the browser window? I have a button that user can press logoff and I can abondan the session but if the user closes the window it doesn't fire. possible at all? -- modified at 1:42 Wednesday 14th September, 2005

        E Offline
        E Offline
        enjoycrack
        wrote on last edited by
        #3

        hi there, Session End will fire when a session is abandoned or times out. This is because the server has no way of knowing when the browser has closed (as www is stateless system). So that is impossible at all :( << >>

        1 Reply Last reply
        0
        • G Guffa

          That is only possible using javascript. In the onunload event, open a new window with a page that does the logoff, and then closes itself. --- b { font-weight: normal; }

          R Offline
          R Offline
          Rahman Mahmoodi
          wrote on last edited by
          #4

          Hi gufa, your suggestion looks very nice. However, wouldn't it be as a pop up window? How if the users has blocked pop up window? Can i do it someway transparents so users really don't know about it ...? sorry, i am not very good in javascript though can figure out what you mean. thanks

          G 1 Reply Last reply
          0
          • R Rahman Mahmoodi

            Hi gufa, your suggestion looks very nice. However, wouldn't it be as a pop up window? How if the users has blocked pop up window? Can i do it someway transparents so users really don't know about it ...? sorry, i am not very good in javascript though can figure out what you mean. thanks

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Yes, it's a popup window. That is the only way to contact the server as the main page is closing. If javascript is disabled, it won't work. If popups are disabled, it won't work. So, it's not ideal, but it's the only way available. The only alternative would be to make the page request data from the server at a set interval, so that you can detect when it stops requesting data. --- b { font-weight: normal; }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups