Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 04, 2012 03:38 AM by Robert Barnes
Apr 03, 2012 11:31 PM|LINK
I have a problem on a page if the session expires. I think I can solve the problem with code that tests for a new session: -
Dim NewSession As Boolean
Dim httpApplication As New HttpApplication
If httpApplication.Session.IsNewSession = True Then
NewSession = True
NewSession = False
If Not Page.IsPostBack OrElse NewSession = True Then
' do first time code .....
This should execute my first-time code when the session has expired, as well as a genuine Not Postback.
How do I test this with Visual Studio? I read somewhere that VS debugger sessions don't expire, so unless I use the production environment for testing (obviously not a good idea) I can't just start a test and wait 20 minutes.
Thank you, Robert.
Apr 04, 2012 01:48 AM|LINK
Correction, my code doesn't work. The statement
If httpApplication.Session.IsNewSession = True Then ...
thows an error:
Apr 04, 2012 03:38 AM|LINK
Dim NewSession As Boolean = False
If Not Page.IsPostBack Then
Session("Table_aspx_session") = "Exists"
ElseIf IsNothing(Session("Table_aspx_session")) Then
NewSession = True ' It must have timed out
It was safe enough, so I tested in on the production site. The name of the session variable, "Table_aspx_session" ensures that it is unique to this page which is table.aspx.