Lose Session Variables

G

Guest

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
 
P

Patrice Scribe

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 said:
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?
 
G

Guest

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
 
P

Patrice Scribe

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 said:
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?
 
G

Guest

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

Guest

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 said:
Added information
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.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?
 
G

Guest

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
 
G

Guest

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?
 
X

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 said:
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?
 
G

Guest

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.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top