Session timeout issue

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

I have a proof of concept app that I am working on.  It is set to be cookieless in the json file and that works correctly.

I have setup code in my program.vb so that my app doesn’t timeout on the sessionTime
AddHandler Application.SessionTimeout, AddressOf Application_SessionTimeout

Private Sub Application_SessionTimeout(sender As Object, e As System.ComponentModel.HandledEventArgs)
e.Handled = True
End Sub

I am loading my for with the standard code in the Sub Main()

Dim window As New Main()
window.Show()

This all works fine, and I can have my app run for hours without anyone touching it.  (It is a dashboard app so it doesn’t need any interaction)

form “main”, If I click on a menu option, it launches a new form using the sub

mnuBill_Run()

Again, this works fine, no timeout

The problem comes when I try to read what form to open from an xml file.  My xml file is this serialized object

Public Class uiSession
Public Property LastAccessed As DateTime = Date.MinValue
Public Property ActiveForm As String = String.Empty

It has 2 methods in it ReadXML and SaveXML

If I use the ReadXML and load the form based off this, my session will time out after about 5 minutes.  The code used to launch the page is the same as above,  mnuBill_Run()

it looks like this:

Dim xsession As New uiSession
xsession = xsession.ReadXML()
If xsession.ActiveForm <> “” Then
Select Case xsession.ActiveForm
Case “frmDashboard_Bill”
mnuBill_Run()

end select

end if

If I delete the XML file, so it passed by the if xsession.activeForm, it doesn’t time out.

So, after all that, why is it timing out if I open the form based off the saved object?

 

Thanks,

Shawn

  • Shawn Ramirez
    I removed the XML from the equation and now have it set to use Dim xsession As New uiSession ‘xsession = xsession.ReadXML() xsession.ActiveForm = “frmDashboard_Bill” If xsession.ActiveForm “” Then Select Case xsession.ActiveForm Case “frmDashboard_Bill” mnuBill_Run() when I do this, I get the timeout. If I comment out the mnuBill_Run() and use the menu option, I do not get the timeout. The menu option code looks like this Private Sub mnuBill_Click(sender As Object, e As EventArgs) Handles mnuBill.Click mnuBill_Run() End Sub Private Sub mnuBill_Run() Dim frm As New frmDashboard_Bill ‘uiSession.SaveSession(frm.Name) frm.LoadData() frm.ShowDialog() End Sub
  • You must to post comments
0
0

Hi Shawn,

It is the issue I described in my last comment. This is what happens in your code:

Execution Path 1: Program.Main -> window.Show() -> AddHandler SessionTimeout -> Done.

User clicks MenuItem1 -> LoadTest() -> frm.LoadData() -> frmShowDialog() -> Modal Idling (thread is suspended).

Timeout event from client -> Application_SessionTimeout -> Handler = true -> Done.

 

Execution Path 2: Program.Main -> window.Show() -> LoadTest() -> frm.LoadData() -> frmShowDialog() -> Modal Idling (thread is suspended).

Timeout event from client -> There is no handler attached since Main() is in a modal loop.

 

Solution: Move AddHandler before window.Show(), or better not use ShowDialog(), use frm.ShowModalMask = true and frm.Show()

/Luca

  • Shawn Ramirez
    Thank you. this took care of my issue. This is one of the differences between WiseJ and VWG (where you can place your addHandler), now that I know that I should be good.
  • Luca (ITG)
    It’s just that we support modal dialogs and VWG didn’t unless you specifically turned it on in Web.config with the setting ModalDialogEmulation Value=”On” inside the WebGUI section. Otherwise in VWG ShowDialog() was not modal and execution continued to the next line. Which causes entire branches of code to have to be rewritten.
  • You must to post comments
0
0

Luca, I have written a really tiny app that demonstrates the problem.

If you run this on a server (not inside of VS2015), you will need to click on the menu option “Test”.  This will open a form that, using a timer will update the time every 2 seconds.

It will run and run and not have the session timeout.

If you go into Window1.vb and uncomment the LoadTest() in the Main_Load and run it, the frmTest form will load, and the timer will update the time label every 2 seconds.  Wait around 6-7 minutes and it will throw up the message that the session will time out in xxx.

Attachment
  • You must to post comments
0
0

One more question, the code that restores the session and calls mnuBill_Run is it invoked when the client gets an invalid session error (after a recycle) and you have the javascript code that reloads?

  • Shawn Ramirez
    I am running it when the main.vb loads (which is loaded by program.vb). It runs every time a session is started, fresh or after an invalid session. However, I also have javascript code that runs when the ex.invalidSession is raised that reloads the application (I used the sample code you added to the forum). In my testing, I took the javascript code out of the equation by commenting it out and still had the issue. If you need me to create a “demo” of this issue, I can try to do that. Let me know. Shawn
  • Luca (ITG)
    Can you send me the lines in Program.Main? If you call frm.ShowDialog() it’s modal and the execution is suspended, the next lines are not executed until after the modal dialog is closed – if you are attaching to SessionTimeout after then it’s not attached while the form is open. When you do the same using the click event, Program.Main has already been executed. Make sure that you attach to SessionTimeout before entering the modal state, or don’t use ShowDialog(), use Show(). If you want to show the modal mask with a non-modal dialog, use frm.ShowModalMask = true, then frm.Show().
  • You must to post comments
0
0

Luca, I am sending you both the XML file and the class that is serialized to it.  You won’t be able to compile it because it uses some external libraries of mine, but you can look at it.

 

Attachment
  • You must to post comments
0
0

Can you send the content of ReadXML? I’m wondering if .NET is creating a dynamic assembly and somehow causes a reload.

  • You must to post comments
Showing 5 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json