Connecting Tech Pros Worldwide Forums | Help | Site Map

Some session variables disappear between postbacks

PJ
Guest
 
Posts: n/a
#1: Nov 18 '05
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




Alvin Bruney [MVP]
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Some session variables disappear between postbacks


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" <pjwal@hotmail.com> wrote in message
news:u8r1Big5DHA.2740@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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[/color]
recyclying[color=blue]
> 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
>
>
>[/color]


PJ
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Some session variables disappear between postbacks


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:OZMCOLh5DHA.3896@TK2MSFTNGP11.phx.gbl...[color=blue]
> You must be clearing these variables somewhere. Can you verify by[/color]
searching[color=blue]
> 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" <pjwal@hotmail.com> wrote in message
> news:u8r1Big5DHA.2740@TK2MSFTNGP09.phx.gbl...[color=green]
> > A particular page seems to be having issues with correctly setting[/color][/color]
Session[color=blue][color=green]
> > variables. I am setting a couple of session variables on the[/color][/color]
Page_Unload[color=blue][color=green]
> > 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[/color][/color]
in[color=blue][color=green]
> > Session. All Session variables that were set previous to that[/color][/color]
particular[color=blue][color=green]
> > page are still there so I know it's not an issue w/ the aspnet_wp[/color]
> recyclying[color=green]
> > 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.[/color][/color]
The[color=blue][color=green]
> > session state is InProc and the values I am setting are simple string
> > values.
> >
> > TIA~PJ
> >
> >
> >[/color]
>
>[/color]


Alvin Bruney [MVP]
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Some session variables disappear between postbacks


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" <pjwal@hotmail.com> wrote in message
news:OHiOris5DHA.2136@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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[/color]
and[color=blue]
> 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[/color]
the[color=blue]
> Session variables were never set. What gives?!!?!
>
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:OZMCOLh5DHA.3896@TK2MSFTNGP11.phx.gbl...[color=green]
> > You must be clearing these variables somewhere. Can you verify by[/color]
> searching[color=green]
> > your project folder that this is not the case? Example, find ALL[/color][/color]
instances[color=blue][color=green]
> > 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" <pjwal@hotmail.com> wrote in message
> > news:u8r1Big5DHA.2740@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > A particular page seems to be having issues with correctly setting[/color][/color]
> Session[color=green][color=darkred]
> > > variables. I am setting a couple of session variables on the[/color][/color]
> Page_Unload[color=green][color=darkred]
> > > event. While stepping through code, the immediate window will show[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > values in Session after the relevant lines that set the variables in[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > Page_Unload event. However, on postback, these variables are no[/color][/color][/color]
longer[color=blue]
> in[color=green][color=darkred]
> > > Session. All Session variables that were set previous to that[/color][/color]
> particular[color=green][color=darkred]
> > > page are still there so I know it's not an issue w/ the aspnet_wp[/color]
> > recyclying[color=darkred]
> > > 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.[/color][/color]
> The[color=green][color=darkred]
> > > session state is InProc and the values I am setting are simple string
> > > values.
> > >
> > > TIA~PJ
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


PJ
Guest
 
Posts: n/a
#5: Nov 18 '05

re: Some session variables disappear between postbacks


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:OmzDFeu5DHA.2072@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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" <pjwal@hotmail.com> wrote in message
> news:OHiOris5DHA.2136@TK2MSFTNGP12.phx.gbl...[color=green]
> > I am deifnately not clearing any session variables. I've rebuilt the[/color][/color]
page[color=blue][color=green]
> > 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[/color]
> and[color=green]
> > 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[/color][/color]
set[color=blue][color=green]
> > in the Page_Unload event are available on PostBack. If I do, it's like[/color]
> the[color=green]
> > Session variables were never set. What gives?!!?!
> >
> >
> > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> > news:OZMCOLh5DHA.3896@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > You must be clearing these variables somewhere. Can you verify by[/color]
> > searching[color=darkred]
> > > your project folder that this is not the case? Example, find ALL[/color][/color]
> instances[color=green][color=darkred]
> > > 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" <pjwal@hotmail.com> wrote in message
> > > news:u8r1Big5DHA.2740@TK2MSFTNGP09.phx.gbl...
> > > > A particular page seems to be having issues with correctly setting[/color]
> > Session[color=darkred]
> > > > variables. I am setting a couple of session variables on the[/color]
> > Page_Unload[color=darkred]
> > > > event. While stepping through code, the immediate window will show[/color][/color]
> the[color=green][color=darkred]
> > > > values in Session after the relevant lines that set the variables in[/color][/color]
> the[color=green][color=darkred]
> > > > Page_Unload event. However, on postback, these variables are no[/color][/color]
> longer[color=green]
> > in[color=darkred]
> > > > Session. All Session variables that were set previous to that[/color]
> > particular[color=darkred]
> > > > 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[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > > what's going on, if anyone has any ideas, I would love to hear them.[/color]
> > The[color=darkred]
> > > > session state is InProc and the values I am setting are simple[/color][/color][/color]
string[color=blue][color=green][color=darkred]
> > > > values.
> > > >
> > > > TIA~PJ
> > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread