Hi,
I'm having some issues holding a session variable after a response.redirect
The code below works perfectly (the Response.Redirect has the parameter false so the code or thread in default.aspx isn't stopped.
However, if I open a connection to a database (ex. access) and close it (I'm not doing any query action on it in my testing code, just opening and closing it) then the session variable gets lost.
I could work with cookies to store the info, but I can't seem to figure out why this session var isn't stored.
Even, in a different web application (created in VS2010, now using VS2012) I have almost the same code without any problems (application properties seem the same, web.config, ...).
All testing is done on my localmachine, using the webserver of VS2012
I'm having some issues holding a session variable after a response.redirect
The code below works perfectly (the Response.Redirect has the parameter false so the code or thread in default.aspx isn't stopped.
Code:
[u]default.aspx[/u]
Session("test") = "ok"
Response.Redirect("home.aspx", false)
[u]home.aspx[/u]
Label1.Text = "session var test = " & Session("test")
However, if I open a connection to a database (ex. access) and close it (I'm not doing any query action on it in my testing code, just opening and closing it) then the session variable gets lost.
Code:
Imports System.Data.OleDb
[u]default.aspx[/u]
dim objConnection As OleDbConnection = New OleDbConnection(MyConnectionString)
objConnection.Open()
objConnection.Close()
Session("test") = "ok"
Response.Redirect("home.aspx", false)
[u]home.aspx[/u]
Label1.Text = "session var test = " & Session("test")
I could work with cookies to store the info, but I can't seem to figure out why this session var isn't stored.
Even, in a different web application (created in VS2010, now using VS2012) I have almost the same code without any problems (application properties seem the same, web.config, ...).
All testing is done on my localmachine, using the webserver of VS2012