By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,028 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,028 IT Pros & Developers. It's quick & easy.

Some session variables disappear between postbacks

P: n/a
PJ
A particular page seems to be having issues with correctly setting Session
variables. I am setting a couple of session variables on the Page_Unload
event. While stepping through code, the immediate window will show the
values in Session after the relevant lines that set the variables in the
Page_Unload event. However, on postback, these variables are no longer in
Session. All Session variables that were set previous to that particular
page are still there so I know it's not an issue w/ the aspnet_wp recyclying
or all of the Session variables clearing. I'm totally at a loss as to
what's going on, if anyone has any ideas, I would love to hear them. The
session state is InProc and the values I am setting are simple string
values.

TIA~PJ

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You must be clearing these variables somewhere. Can you verify by searching
your project folder that this is not the case? Example, find ALL instances
of session and examine them. If all is well, post your code here.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
A particular page seems to be having issues with correctly setting Session
variables. I am setting a couple of session variables on the Page_Unload
event. While stepping through code, the immediate window will show the
values in Session after the relevant lines that set the variables in the
Page_Unload event. However, on postback, these variables are no longer in
Session. All Session variables that were set previous to that particular
page are still there so I know it's not an issue w/ the aspnet_wp recyclying or all of the Session variables clearing. I'm totally at a loss as to
what's going on, if anyone has any ideas, I would love to hear them. The
session state is InProc and the values I am setting are simple string
values.

TIA~PJ

Nov 18 '05 #2

P: n/a
PJ
I am deifnately not clearing any session variables. I've rebuilt the page
piece by piece and it seems to be caused by the DataBind statement on a
repeater in the page. I removed all events associated with the repeater and
set it's DataSource to a simple string array and the same problem still
occurred. If I don't databind the repeater, then the session values I set
in the Page_Unload event are available on PostBack. If I do, it's like the
Session variables were never set. What gives?!!?!
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
You must be clearing these variables somewhere. Can you verify by searching your project folder that this is not the case? Example, find ALL instances
of session and examine them. If all is well, post your code here.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the immediate window will show the
values in Session after the relevant lines that set the variables in the
Page_Unload event. However, on postback, these variables are no longer in Session. All Session variables that were set previous to that particular page are still there so I know it's not an issue w/ the aspnet_wp

recyclying
or all of the Session variables clearing. I'm totally at a loss as to
what's going on, if anyone has any ideas, I would love to hear them. The session state is InProc and the values I am setting are simple string
values.

TIA~PJ


Nov 18 '05 #3

P: n/a
post the code. are you doing anything funny/different? any customizations?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
I am deifnately not clearing any session variables. I've rebuilt the page
piece by piece and it seems to be caused by the DataBind statement on a
repeater in the page. I removed all events associated with the repeater and set it's DataSource to a simple string array and the same problem still
occurred. If I don't databind the repeater, then the session values I set
in the Page_Unload event are available on PostBack. If I do, it's like the Session variables were never set. What gives?!!?!
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
You must be clearing these variables somewhere. Can you verify by searching
your project folder that this is not the case? Example, find ALL instances
of session and examine them. If all is well, post your code here.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
A particular page seems to be having issues with correctly setting

Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the immediate window will show the values in Session after the relevant lines that set the variables in the Page_Unload event. However, on postback, these variables are no
longer in Session. All Session variables that were set previous to that particular page are still there so I know it's not an issue w/ the aspnet_wp

recyclying
or all of the Session variables clearing. I'm totally at a loss as to
what's going on, if anyone has any ideas, I would love to hear them. The session state is InProc and the values I am setting are simple string
values.

TIA~PJ



Nov 18 '05 #4

P: n/a
PJ
The session variable "foldersXml" is the session variable that finds itself
not available during postback.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.SmartNavigation = False
If Not Me.IsPostBack Then
If Request("keep") Is Nothing Then
GetData()
Else
RefreshData()
End If
SetupUI()
BindData()
Else
RefreshData()
End If
End Sub

Private Sub Page_Unload(ByVal sender As Object, ByVal e As EventArgs)
Handles MyBase.Unload
Session("foldersXml") = folderList.GetXml()
Session("chooserList") = Nothing
End Sub

Private Sub SetupUI()
Me.breadCrumbNav.AddCrumb("Admin",
Me.ResolveUrl("~/admin/adminmain.aspx"), 1)
Me.breadCrumbNav.AddCrumb("Folders",
Me.ResolveUrl("~/admin/folderlist.aspx"), 2)
lblDivision.Text = Me.CurrentDivision.Name.ToUpper()
End Sub

Private Sub GetData()
folderList = B2BFolderFactory.CreateAdminFolders(Me.CurrentDivi sion,
Nothing)
End Sub

Private Sub RefreshData()
'refresh the folder list from the xml string of folder id's
Dim foldersXml As String = CType(Session("foldersXml"), String)
If foldersXml Is Nothing Then
Response.Redirect(Me.REDIRECT_URL)
End If
folderList = B2BFolderFactory.CreateAdminFolders(foldersXml)
'resort a folder if requested ( for name changes from detail page )
If IsNumeric(Request("resort")) Then
folderList.ResortFolder(Convert.ToInt32(Request("r esort")))
End If
End Sub

Private Sub BindData()
maxDepth = folderList.GetMaxDepth()
rptMain.DataSource = folderList
rptMain.DataBind()
End Sub

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
post the code. are you doing anything funny/different? any customizations?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
I am deifnately not clearing any session variables. I've rebuilt the page
piece by piece and it seems to be caused by the DataBind statement on a
repeater in the page. I removed all events associated with the repeater

and
set it's DataSource to a simple string array and the same problem still
occurred. If I don't databind the repeater, then the session values I set in the Page_Unload event are available on PostBack. If I do, it's like

the
Session variables were never set. What gives?!!?!
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:OZ**************@TK2MSFTNGP11.phx.gbl...
You must be clearing these variables somewhere. Can you verify by

searching
your project folder that this is not the case? Example, find ALL

instances of session and examine them. If all is well, post your code here.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"PJ" <pj***@hotmail.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
> A particular page seems to be having issues with correctly setting

Session
> variables. I am setting a couple of session variables on the

Page_Unload
> event. While stepping through code, the immediate window will show the > values in Session after the relevant lines that set the variables in the > Page_Unload event. However, on postback, these variables are no

longer
in
> Session. All Session variables that were set previous to that

particular
> page are still there so I know it's not an issue w/ the aspnet_wp
recyclying
> or all of the Session variables clearing. I'm totally at a loss as to > what's going on, if anyone has any ideas, I would love to hear them.

The
> session state is InProc and the values I am setting are simple string > values.
>
> TIA~PJ
>
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.