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

Lose Session Variables

P: n/a
I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of my pages I set a date in a dropdownlist (autopostback=false) and then click a "Build" button which builds a report. Most of the time there is no problem. But sometimes the following happens. I step through the code no problem, the session variables do not change. But, when examined after the the next mouse click, the session variables are GONE! It has nothing to do with time or antivirus protection. Any ideas

Thanks

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


P: n/a
Check out the sessionid value to make sure the session changed...

AFAIK it can happens also if the application automatically restarted server
side...

Patrice

--

"Michael SL" <mi*****************@compuware.com> a écrit dans le message de
news:D7**********************************@microsof t.com...
I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of my
pages I set a date in a dropdownlist (autopostback=false) and then click a
"Build" button which builds a report. Most of the time there is no problem.
But sometimes the following happens. I step through the code no problem,
the session variables do not change. But, when examined after the the next
mouse click, the session variables are GONE! It has nothing to do with time
or antivirus protection. Any ideas?
Thanks,

Michael


Nov 18 '05 #2

P: n/a
Will you post some code so we can see what is going on?
Nov 18 '05 #3

P: n/a
Added informatio

I am using Visual Studio. I have set up some breakpoints. When I hit the breakpoints I click on the breakpoints filled circle indicator and it turn into the empty circle (meaning that the breakpoint is temporarily disabled for this execution). Now, the code continually passes over the disabled breakpoint until I set TheStartDate to some particular values and perform a Build. The next time the code hits the breakpoint it stops. This indicates that Visual Studio did do a reset. But why I have no idea. As stated before, it is not time. I do not see anything it the code which would cause it. I just don't get it

Michae

----- Michael SL wrote: ----

I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of my pages I set a date in a dropdownlist (autopostback=false) and then click a "Build" button which builds a report. Most of the time there is no problem. But sometimes the following happens. I step through the code no problem, the session variables do not change. But, when examined after the the next mouse click, the session variables are GONE! It has nothing to do with time or antivirus protection. Any ideas

Thanks

Michael
Nov 18 '05 #4

P: n/a
Do you mean this is when perform a build ? It updates the DLL in your /bin
folder which is likely to restart the application.

Do you have the same behavior when you just test your application using
simply the browser ?

--

"Michael SL" <mi*****************@compuware.com> a écrit dans le message de
news:57**********************************@microsof t.com...
Added information

I am using Visual Studio. I have set up some breakpoints. When I hit the breakpoints I click on the breakpoints filled circle indicator and it turn
into the empty circle (meaning that the breakpoint is temporarily disabled
for this execution). Now, the code continually passes over the disabled
breakpoint until I set TheStartDate to some particular values and perform a
Build. The next time the code hits the breakpoint it stops. This indicates
that Visual Studio did do a reset. But why I have no idea. As stated
before, it is not time. I do not see anything it the code which would cause
it. I just don't get it.
Michael

----- Michael SL wrote: -----

I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of
my pages I set a date in a dropdownlist (autopostback=false) and then click
a "Build" button which builds a report. Most of the time there is no
problem. But sometimes the following happens. I step through the code no
problem, the session variables do not change. But, when examined after the
the next mouse click, the session variables are GONE! It has nothing to do
with time or antivirus protection. Any ideas?
Thanks,

Michael


Nov 18 '05 #5

P: n/a
2ND ATTEMP AT REPLY - FOR SOME REASON MY PREVIOUS REPLY DID NOT POST

There is a ton of code but I will give you some of it. If you need more, let me know.

From the aspx file:
<asp:dropdownlist id="TheStartDate" runat="server" AutoPostBack="False" Width="120px"></asp:dropdownlist><asp:dropdownlist id="TheEndDate" runat="server" AutoPostBack="False" Width="120px"></asp:dropdownlist><asp:button id="btnBuild" runat="server" Text="Build"></asp:button><TextArea id="Summary" onmouseup="SumMouseUp()" onkeyup="SumMouseUp()" style="WIDTH: 90%" name="Summary" rows="25" runat="server"></TextArea>

From the login aspx.vb file:
Dim tempStr As String
tempStr = Me.TemplateSourceDirectory
Session("Top") = "\" + Right(tempStr, Len(tempStr) - 1)

From the button processing aspx.vb file:
Private Sub btnBuild_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuild.Click
Dim EndDate As Date
Dim sEndDate As String
Dim sStartDate As String
Dim StartDate As Date

Msg.Text = ""

sStartDate = TheStartDate.SelectedValue
sEndDate = TheEndDate.SelectedValue

StartDate = CType(sStartDate, DateTime)
EndDate = CType(sEndDate, DateTime)

If EndDate >= StartDate Then
BuildSummary(StartDate, EndDate)

btnAddBuild.Visible = True
btnAddBuild.Enabled = True
btnFinalize.Enabled = True
btnFinalize.Visible = True
btnSave.Enabled = True
lblReportName.Visible = True
SaveReportName.ReadOnly = False
SaveReportName.Visible = True
Summary.Attributes.Remove("readonly")
Summary.Visible = True
btnSave.Visible = True

Else
Msg.Text = "Invalid Selection: End Date cannot be earlier than Start Date."
End If
End Sub 'btnBuild_Click

The 'BuildSummary' function is quite complex. It creates and fills tables as well as accessing an Access Database and uses the results to build summary.value. I do not have any idea what in the code would cause a restart but with the right data if happens consistantly.
Nov 18 '05 #6

P: n/a
Patrice

Whenever I execute from Visual Studio it rebuilds the application (updating the DLL) and runs. Now when I process with certain data I lose my session variables. The same thing happens if I access the web page from another PC. It works fine until I build a report using a different start date. After that the session variables are lost.

Michael

----- Patrice Scribe wrote: -----

Do you mean this is when perform a build ? It updates the DLL in your /bin
folder which is likely to restart the application.

Do you have the same behavior when you just test your application using
simply the browser ?

--

"Michael SL" <mi*****************@compuware.com> a écrit dans le message de
news:57**********************************@microsof t.com...
Added information
I am using Visual Studio. I have set up some breakpoints. When I hit the breakpoints I click on the breakpoints filled circle indicator and it turn
into the empty circle (meaning that the breakpoint is temporarily disabled
for this execution). Now, the code continually passes over the disabled
breakpoint until I set TheStartDate to some particular values and perform a
Build. The next time the code hits the breakpoint it stops. This indicates
that Visual Studio did do a reset. But why I have no idea. As stated
before, it is not time. I do not see anything it the code which would cause
it. I just don't get it. Michael
----- Michael SL wrote: -----
I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of
my pages I set a date in a dropdownlist (autopostback=false) and then click
a "Build" button which builds a report. Most of the time there is no
problem. But sometimes the following happens. I step through the code no
problem, the session variables do not change. But, when examined after the
the next mouse click, the session variables are GONE! It has nothing to do
with time or antivirus protection. Any ideas? Thanks,
Michael

Nov 18 '05 #7

P: n/a
New Informatio

I have narrowed it down to one small bit of code
Public Class AdministratorRepor
..
Dim AssignDT As DataTabl
..
Private Sub BuildSummary(ByVal StartDate As Date, ByVal EndDate As Date, Optional ByVal IsAdd As Boolean = False
..
Dim dc As DataColum
Dim dr As DataRo
..
AssignDT = New DataTabl

dc = New DataColumn("ProjectID"
AssignDT.Columns.Add(dc

dc = New DataColumn("EmpName"
AssignDT.Columns.Add(dc

dc = New DataColumn("Date"
AssignDT.Columns.Add(dc

..
If ... The
..
dr = AssignDT.NewRow(
dr("ProjectID") = reader1(0
dr("EmpName") = reader1(1
dr("Date") = DBDat
AssignDT.Rows.Add(dr
..
End I

If a button click causes the AssignDT.Rows.Add(dr) to execute 7 or less times, it works just fine. If that same button click causes the AssignDT.Rows.Add(dr) to execute more than 7 times after posting I lose my session variables. I have tried inserting an AssignDT.AcceptChanges() after the .Rows.Add, it did not help. Any Ideas

Thanks

Michael
Nov 18 '05 #8

P: n/a
Ignore the previous posting. This seems to be a timing issue. If I place a breakpoint within the loop that processes the DataTable, IT WORKS JUST FINE. If I let it run full speed, IT FAILS. Now I have to try to figure a way to slow it down - ANY SUGGESTIONS?
Nov 18 '05 #9

P: n/a
Xis
Hi Michael,

I'm having similar problem.

I'm using session variables to store user data. I can go to several pages
and session remain. But with one page, where I create a datagrid, after load
first time this page session still are there, if I click or refresh anywhere
in the page, session variables are lost, but session ID still remain.

Do you have any idea about my problem?

"Michael SL" <mi*****************@compuware.com> escribi en el mensaje
news:D7**********************************@microsof t.com...
I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of my
pages I set a date in a dropdownlist (autopostback=false) and then click a
"Build" button which builds a report. Most of the time there is no problem.
But sometimes the following happens. I step through the code no problem,
the session variables do not change. But, when examined after the the next
mouse click, the session variables are GONE! It has nothing to do with time
or antivirus protection. Any ideas?
Thanks,

Michael

Nov 18 '05 #10

P: n/a
In this newsgroup:
Search for Michael SL
Look in Lost Session Variables (instead of Lose Session Variables)

I have solved my problem using cookies. They do not go away.
Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.