WebPage Close Event Cannot Access Session Properties?

Hi, In my Web app I am trying to use the WebPage.Close event to save the details of a record being edited. This is necessary for when a Session times out, or when I want to force users off the app in a controlled manner. The key for the record is stored in Session.ReportNo.

In the Web Page Close event, the I have the code:


I know for sure that Session.ReportNo always has the right key stored when a record is accessed, but in the Close event, it is always ZERO.

In the Session.TimedOut event, I have the code:

    Dim c as Integer = Session.PageCount-1

    For i As Integer = c DownTo 0 Step 1

Anyone know why Session variables are not available from the Close event? Is the Web Page already closed when the Close event fires? If so, what is Close for? Any help will be much appreciated.

Also - when Session.TimedOut runs, have all Web Pages already been closed?

No. It is simply a trigger from the browser saying that the user has not typed or moved their mouse in a while.

If it’s zero and you are not getting exceptions, my guess is that it’s being SET to zero somewhere. You could try converting it to a computed property and then set a breakpoint in the setter to figure that out.