473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Lose Session Variables

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
10 1684
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
Will you post some code so we can see what is going on?
Nov 18 '05 #3
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
4
by: PJ | last post by:
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...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
2
by: Tomas Martinez | last post by:
Hi, Well, my problem is so simple as it says in the subjet but very frustrating also. I have a project and it is losing the session variables with each postback, so I downloaded from the web a...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
7
by: robert.waters | last post by:
Why do my public variables (including class instances) disappear when my app experiences an unhandled error? My custom class module's class_terminate event doesn't even fire, the instance just...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.