Some session variables disappear between postbacks

P

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
 
A

Alvin Bruney [MVP]

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.
 
P

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 said:
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 said:
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
 
A

Alvin Bruney [MVP]

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 said:
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 said:
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 said:
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
 
P

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.CurrentDivision,
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("resort")))
End If
End Sub

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

Alvin Bruney said:
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 said:
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 said:
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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top