Session_End only working when browser is left open

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vickyl
    New Member
    • Sep 2008
    • 5

    Session_End only working when browser is left open

    Hi,

    I've been having this problem for the pas few days so i thought i'd post and see if anyone could help.

    I have an application that has code to delete file in Session_end. When i start a session and then do nothing in the browser for the timeout amount of time, session_end fires and the code works....the files get deleted. However, if i close the browser and wait the same amount of time (or longer) Session_End never fires. I know that closing the browser doesn't call session_end.... i am actually waiting the timeout amount of time but Session_end just never fires.....Is there something about Session_end and closing browsers that i am not aware of?

    Thanks in advance to anyone who can help :)

    vicky
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Session_End() should fire after the timeout time, regardless of if browser is left open or is closed.
    Is your Session type set to "InProc" (I think that's the default)

    Comment

    • vickyl
      New Member
      • Sep 2008
      • 5

      #3
      yes it is InProc

      this seems very bizarre to me....

      Comment

      • vickyl
        New Member
        • Sep 2008
        • 5

        #4
        this is the code i have in my session_end. i am testing on my machine and no one else has access so session.count should always be 1....which it is when i keep the browser open....but seems to change when i close the browser:


        Sub Session_End(ByV al sender As Object, ByVal e As EventArgs)
        If session.Count = 1
        Dim s As String
        Dim path As String = HttpRuntime.App DomainAppPath

        For Each s In System.IO.Direc tory.GetFiles(p ath + "\TempReference Files\")
        System.IO.File. Delete(s)
        Next s
        End If
        End Sub

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Why do that at every session_end(), wouldn't that mess up anyone else trying to use the stite?
          You could do it in Application_End ()?

          EDIT:
          As for why the session count goes up, when you close your browser and then goto website again, you will get a new session, so the count will go up.

          Comment

          • vickyl
            New Member
            • Sep 2008
            • 5

            #6
            well that's why i check if any other sessions are open....if there are more than one it doesn't delete (at least that's what i'm trying to do).

            also, at the moment i have my timaout set at 1 minute for testing purposes and i'm not opening any other browsers.....so there should only always be 1 session open at a time

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              As far as my testings have shown, when the last session "ends", the Application_End () event fires

              Comment

              • vickyl
                New Member
                • Sep 2008
                • 5

                #8
                ok i may have misunderstood the session_end.... i was under the impression that it fired every time a session would timeout....not just the last one

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  Originally posted by vickyl
                  ok i may have misunderstood the session_end.... i was under the impression that it fired every time a session would timeout....not just the last one
                  No you are correct, it *should* fire for every session that ends (as long as session is listed as "InProc"). However after the last session has ended, my application seems to call the application_end () function and shut itself down.

                  Comment

                  Working...