G
Guest
I save a session variable on page 1 and link to page 2. When page 2 loads,
the session variable is null. Can anyone help?
I'm using Visual Studio 2003 (VB)
Session settings in web.config
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Code on Page 1
Dim sesvar As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
sesvar = "Blank Statement"
Me.ShowSessionVar.Text = sesvar
End Sub
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveButton.Click
sesvar = "New Session Variable at " + Format(Now(), "dd/mm/yyyy
hh:mm:ss")
Me.ShowSessionVar.Text = sesvar
Session("SesMessage") = sesvar.ToString
End Sub
code on page 2
Dim P2sesvar As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("SesMessage") Is Nothing Then
P2sesvar = "Session Variable is Null"
Else
P2sesvar = Session("SesMessage")
End If
Me.P2SessionVar.Text = P2sesvar
End Sub
the session variable is null. Can anyone help?
I'm using Visual Studio 2003 (VB)
Session settings in web.config
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Code on Page 1
Dim sesvar As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
sesvar = "Blank Statement"
Me.ShowSessionVar.Text = sesvar
End Sub
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveButton.Click
sesvar = "New Session Variable at " + Format(Now(), "dd/mm/yyyy
hh:mm:ss")
Me.ShowSessionVar.Text = sesvar
Session("SesMessage") = sesvar.ToString
End Sub
code on page 2
Dim P2sesvar As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("SesMessage") Is Nothing Then
P2sesvar = "Session Variable is Null"
Else
P2sesvar = Session("SesMessage")
End If
Me.P2SessionVar.Text = P2sesvar
End Sub