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

Session and Application Variables dissappearing

P: n/a
I have a problem, mentioned here before, of Session and Application
variables disappearing at one site but not at others or on my development
computer.

The problem is illustrated by an example at
http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session,
Application and Cache variables on the first page and then on the second
page view them as the second page is refreshed every five seconds. Before
10 refreshes, the variables have disappeared. Strangely, at least to me,
the Session Id can still be retrieved. So, under what circumstances do you
retain the Session ID but lose the Session variables?

The pages are hosted on a Windows 2003 server in a shared environment, but
not on a web farm. I have no control over this server, but the web host has
tried to solve the problem. However, they have not produced a solution.

What could be causing this?
Nov 18 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Where are you storing and passing session_id? The first thing which comes to
mind is examining the request recycle parameter in IIS management. Check to
see if it is set too low. If session_id is in the cache, my idea is totally
wrong. Post your code for that test page. This has definitely got my
interest.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:#x**************@TK2MSFTNGP09.phx.gbl...
I have a problem, mentioned here before, of Session and Application
variables disappearing at one site but not at others or on my development
computer.

The problem is illustrated by an example at
http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session,
Application and Cache variables on the first page and then on the second
page view them as the second page is refreshed every five seconds. Before
10 refreshes, the variables have disappeared. Strangely, at least to me,
the Session Id can still be retrieved. So, under what circumstances do you retain the Session ID but lose the Session variables?

The pages are hosted on a Windows 2003 server in a shared environment, but
not on a web farm. I have no control over this server, but the web host has tried to solve the problem. However, they have not produced a solution.

What could be causing this?

Nov 18 '05 #2

P: n/a
I am not storing the Session ID. It is retrieved on every page reload of
the SessionTestView.aspx page.

Here is the code that sets the session and application variables in the page
sessiontestset.aspx:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Application("Text") = "ABCDEF"
Session("Text") = "12345"
Cache.Add("Text", "STUVWXYZ", Nothing, DateTime.Now.AddMinutes(10),
TimeSpan.Zero, Caching.CacheItemPriority.AboveNormal, Nothing)
Response.Redirect("SessionTestView.aspx")
End Sub

Here is the code that displays the information in the page
SessionTestView.aspx (this page reloads every five seconds):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.lblTime.Text = Now.ToString
Me.lblApplication.Text = "Application Variable: " &
Application("Text")
Me.lblSession.Text = "Session Variable: " & Session("Text")
Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")
Me.lblID.Text = "Session ID: " & Session.SessionID.ToString
End Sub

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:OL**************@TK2MSFTNGP12.phx.gbl...
Where are you storing and passing session_id? The first thing which comes to mind is examining the request recycle parameter in IIS management. Check to see if it is set too low. If session_id is in the cache, my idea is totally wrong. Post your code for that test page. This has definitely got my
interest.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:#x**************@TK2MSFTNGP09.phx.gbl...
I have a problem, mentioned here before, of Session and Application
variables disappearing at one site but not at others or on my development computer.

The problem is illustrated by an example at
http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session,
Application and Cache variables on the first page and then on the second
page view them as the second page is refreshed every five seconds. Before 10 refreshes, the variables have disappeared. Strangely, at least to me, the Session Id can still be retrieved. So, under what circumstances do

you
retain the Session ID but lose the Session variables?

The pages are hosted on a Windows 2003 server in a shared environment, but not on a web farm. I have no control over this server, but the web host

has
tried to solve the problem. However, they have not produced a solution.

What could be causing this?


Nov 18 '05 #3

P: n/a
ok check your settings in IIS. If this is IIS6 you want to check the
application pool properties recycle events and application shut down events
to see what they are set to. If this is ok, you will need to check your
config files for idletime directives in the process model node to see what
they are set to. If this is ok move on to the machine config file and check
the httpruntime nodes to see the recycling directives

regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:eA*************@tk2msftngp13.phx.gbl...
I am not storing the Session ID. It is retrieved on every page reload of
the SessionTestView.aspx page.

Here is the code that sets the session and application variables in the page sessiontestset.aspx:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Application("Text") = "ABCDEF"
Session("Text") = "12345"
Cache.Add("Text", "STUVWXYZ", Nothing, DateTime.Now.AddMinutes(10), TimeSpan.Zero, Caching.CacheItemPriority.AboveNormal, Nothing)
Response.Redirect("SessionTestView.aspx")
End Sub

Here is the code that displays the information in the page
SessionTestView.aspx (this page reloads every five seconds):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.lblTime.Text = Now.ToString
Me.lblApplication.Text = "Application Variable: " &
Application("Text")
Me.lblSession.Text = "Session Variable: " & Session("Text")
Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")
Me.lblID.Text = "Session ID: " & Session.SessionID.ToString
End Sub

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:OL**************@TK2MSFTNGP12.phx.gbl...
Where are you storing and passing session_id? The first thing which comes
to
mind is examining the request recycle parameter in IIS management. Check

to
see if it is set too low. If session_id is in the cache, my idea is

totally
wrong. Post your code for that test page. This has definitely got my
interest.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:#x**************@TK2MSFTNGP09.phx.gbl...
I have a problem, mentioned here before, of Session and Application
variables disappearing at one site but not at others or on my development computer.

The problem is illustrated by an example at
http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second page view them as the second page is refreshed every five seconds. Before 10 refreshes, the variables have disappeared. Strangely, at least to me, the Session Id can still be retrieved. So, under what circumstances do you
retain the Session ID but lose the Session variables?

The pages are hosted on a Windows 2003 server in a shared environment, but not on a web farm. I have no control over this server, but the web
host has
tried to solve the problem. However, they have not produced a

solution.
What could be causing this?



Nov 18 '05 #4

P: n/a
I don't have access to this particular web server, so I have to request the
hosting company check. Thus I need to be specific.

It is IIS6. Is "application pool properties recycle events" the exact name
of the setting and what sort of value should it have? The same for
application shut down events.

I would love to figure this out, since I only have such problems on this
server. However, I have a number of sites hosted with his company and would
like to put more asp.net stuff on them if I can figure out Session variable
problem.

Here is the response from the hosting company when I first mentioned the
problem to them. Is it possible that some other user accessing a different
page is causing this problem:

your website has been moved into its own application pool, sharing it with
no one else. The logs indicate that the pool is failing when trying to run
some of your scripts. Operations suggest that there may be one small piece
of code somewhere in some of your pages which may be causing this, as your
website has been isolated on its own, and the pool that you were in
previously has not failed anymore.
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:uL****************@TK2MSFTNGP12.phx.gbl...
ok check your settings in IIS. If this is IIS6 you want to check the
application pool properties recycle events and application shut down events to see what they are set to. If this is ok, you will need to check your
config files for idletime directives in the process model node to see what
they are set to. If this is ok move on to the machine config file and check the httpruntime nodes to see the recycling directives

regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:eA*************@tk2msftngp13.phx.gbl...
I am not storing the Session ID. It is retrieved on every page reload of
the SessionTestView.aspx page.

Here is the code that sets the session and application variables in the

page
sessiontestset.aspx:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Application("Text") = "ABCDEF"
Session("Text") = "12345"
Cache.Add("Text", "STUVWXYZ", Nothing,

DateTime.Now.AddMinutes(10),
TimeSpan.Zero, Caching.CacheItemPriority.AboveNormal, Nothing)
Response.Redirect("SessionTestView.aspx")
End Sub

Here is the code that displays the information in the page
SessionTestView.aspx (this page reloads every five seconds):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.lblTime.Text = Now.ToString
Me.lblApplication.Text = "Application Variable: " &
Application("Text")
Me.lblSession.Text = "Session Variable: " & Session("Text")
Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")
Me.lblID.Text = "Session ID: " & Session.SessionID.ToString
End Sub

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in message news:OL**************@TK2MSFTNGP12.phx.gbl...
Where are you storing and passing session_id? The first thing which comes
to
mind is examining the request recycle parameter in IIS management.

Check to
see if it is set too low. If session_id is in the cache, my idea is

totally
wrong. Post your code for that test page. This has definitely got my
interest.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:#x**************@TK2MSFTNGP09.phx.gbl...
> I have a problem, mentioned here before, of Session and Application
> variables disappearing at one site but not at others or on my

development
> computer.
>
> The problem is illustrated by an example at
> http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, > Application and Cache variables on the first page and then on the second > page view them as the second page is refreshed every five seconds.

Before
> 10 refreshes, the variables have disappeared. Strangely, at least
to me,
> the Session Id can still be retrieved. So, under what circumstances do you
> retain the Session ID but lose the Session variables?
>
> The pages are hosted on a Windows 2003 server in a shared
environment, but
> not on a web farm. I have no control over this server, but the web

host has
> tried to solve the problem. However, they have not produced a solution. >
> What could be causing this?
>
>



Nov 18 '05 #5

P: n/a
I think they are right.
problem to them. Is it possible that some other user accessing a different page is causing this problem: no, each user has his own stuff as long as the ...wait let me look at
something here...

Me.lblApplication.Text = "Application Variable: " &
Application("Text")
Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")
this two lines will cause problems because these items are exposed to every
user hitting the website. You want to put them in session variables so they
are specific to a user. so that's one thing.

It likely is your code because of what they said. A wild guess? You have an
exception killing your cache objects. You will need to do some old fashion
debugging to figure this out. The problem most likely lies in your code.
Here is one place to begin. Remove all your catch blocks in your entire
application. In your application_error event, put script to display
Context.Error msg. Also, write a message to a static variable in your
session_end event in your global asax file. You need to see when the session
is ending. It may be ending prematurely. Put a button on the form to read
this static variable. Then test the page like you normally would. Any
exception will be displayed to the screen and you can go from there. I
figure you will have to debug on the server since the problem doesn't occur
on your machine.
It aint no picnic though, but have fun on the way.

regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl... I don't have access to this particular web server, so I have to request the hosting company check. Thus I need to be specific.

It is IIS6. Is "application pool properties recycle events" the exact name of the setting and what sort of value should it have? The same for
application shut down events.

I would love to figure this out, since I only have such problems on this
server. However, I have a number of sites hosted with his company and would like to put more asp.net stuff on them if I can figure out Session variable problem.

Here is the response from the hosting company when I first mentioned the
problem to them. Is it possible that some other user accessing a different page is causing this problem:

your website has been moved into its own application pool, sharing it with
no one else. The logs indicate that the pool is failing when trying to run some of your scripts. Operations suggest that there may be one small piece of code somewhere in some of your pages which may be causing this, as your
website has been isolated on its own, and the pool that you were in
previously has not failed anymore.
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:uL****************@TK2MSFTNGP12.phx.gbl...
ok check your settings in IIS. If this is IIS6 you want to check the
application pool properties recycle events and application shut down

events
to see what they are set to. If this is ok, you will need to check your
config files for idletime directives in the process model node to see what
they are set to. If this is ok move on to the machine config file and

check
the httpruntime nodes to see the recycling directives

regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:eA*************@tk2msftngp13.phx.gbl...
I am not storing the Session ID. It is retrieved on every page reload of the SessionTestView.aspx page.

Here is the code that sets the session and application variables in
the page
sessiontestset.aspx:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Application("Text") = "ABCDEF"
Session("Text") = "12345"
Cache.Add("Text", "STUVWXYZ", Nothing,

DateTime.Now.AddMinutes(10),
TimeSpan.Zero, Caching.CacheItemPriority.AboveNormal, Nothing)
Response.Redirect("SessionTestView.aspx")
End Sub

Here is the code that displays the information in the page
SessionTestView.aspx (this page reloads every five seconds):

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.lblTime.Text = Now.ToString
Me.lblApplication.Text = "Application Variable: " &
Application("Text")
Me.lblSession.Text = "Session Variable: " & Session("Text")
Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")
Me.lblID.Text = "Session ID: " & Session.SessionID.ToString
End Sub

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in message news:OL**************@TK2MSFTNGP12.phx.gbl...
> Where are you storing and passing session_id? The first thing which

comes
to
> mind is examining the request recycle parameter in IIS management. Check to
> see if it is set too low. If session_id is in the cache, my idea is
totally
> wrong. Post your code for that test page. This has definitely got my
> interest.
>
> regards
>
> --
>
>
> -----------
> Got TidBits?
> Get it here: www.networkip.net/tidbits
> "William LaMartin" <la******@tampabay.rr.com> wrote in message
> news:#x**************@TK2MSFTNGP09.phx.gbl...
> > I have a problem, mentioned here before, of Session and
Application > > variables disappearing at one site but not at others or on my
development
> > computer.
> >
> > The problem is illustrated by an example at
> > http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set

Session,
> > Application and Cache variables on the first page and then on the

second
> > page view them as the second page is refreshed every five seconds.
Before
> > 10 refreshes, the variables have disappeared. Strangely, at least

to me,
> > the Session Id can still be retrieved. So, under what
circumstances do
> you
> > retain the Session ID but lose the Session variables?
> >
> > The pages are hosted on a Windows 2003 server in a shared environment, but
> > not on a web farm. I have no control over this server, but the

web host
> has
> > tried to solve the problem. However, they have not produced a

solution.
> >
> > What could be causing this?
> >
> >
>
>



Nov 18 '05 #6

P: n/a
I don't think it is my code, since at this other test site,
http://216.182.10.243/container/SessionTestSet.aspx, the variables don't
disappear. So it is something specific to the lamartin.com site
(http://www.lamartin.com/dotnet/sessiontestset.aspx). At lamartin.com, they
say they have put me in my own application pool, so it must be some other
setting.

I put the Application variable and the cached variable there only to see if
they would also disappear, and they do--at the same time the Session
variable does.

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:eC**************@TK2MSFTNGP12.phx.gbl...
I think they are right.
problem to them. Is it possible that some other user accessing a different
page is causing this problem:

no, each user has his own stuff as long as the ...wait let me look at
something here...

Me.lblApplication.Text = "Application Variable: " &
> Application("Text")
> Me.lblCache.Text = "Cached Variable: " & Cache.Item("Text")


this two lines will cause problems because these items are exposed to

every user hitting the website. You want to put them in session variables so they are specific to a user. so that's one thing.

It likely is your code because of what they said. A wild guess? You have an exception killing your cache objects. You will need to do some old fashion
debugging to figure this out. The problem most likely lies in your code.
Here is one place to begin. Remove all your catch blocks in your entire
application. In your application_error event, put script to display
Context.Error msg. Also, write a message to a static variable in your
session_end event in your global asax file. You need to see when the session is ending. It may be ending prematurely. Put a button on the form to read
this static variable. Then test the page like you normally would. Any
exception will be displayed to the screen and you can go from there. I
figure you will have to debug on the server since the problem doesn't occur on your machine.
It aint no picnic though, but have fun on the way.

regards

Nov 18 '05 #7

P: n/a
Ok, well have them make these setting adjustments:
From the application pool property pages in IIS, uncheck all settings under
the Recycle tab (4)
From the Performance tab, uncheck the first two (Idle timeout and request
queue limit)
From the Health tab, uncheck Enable rapid-fail protection.

Let them know it is for debugging purposes because they might not be willing
as these settings compromise the stability of the server. In addition, have
them examine the idletimeout property in the machine config file to see what
it is set to. The default is Infinite otherwise it is a time period
00:00:00.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:OT**************@tk2msftngp13.phx.gbl...
I don't think it is my code, since at this other test site,
http://216.182.10.243/container/SessionTestSet.aspx, the variables don't
disappear. So it is something specific to the lamartin.com site
(http://www.lamartin.com/dotnet/sessiontestset.aspx). At lamartin.com, they say they have put me in my own application pool, so it must be some other
setting.

I put the Application variable and the cached variable there only to see if they would also disappear, and they do--at the same time the Session
variable does.

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:eC**************@TK2MSFTNGP12.phx.gbl...
I think they are right.
problem to them. Is it possible that some other user accessing a

different
page is causing this problem:

no, each user has his own stuff as long as the ...wait let me look at
something here...

Me.lblApplication.Text = "Application Variable: " &
> > Application("Text")
> > Me.lblCache.Text = "Cached Variable: " &
Cache.Item("Text")
this two lines will cause problems because these items are exposed to

every
user hitting the website. You want to put them in session variables so

they
are specific to a user. so that's one thing.

It likely is your code because of what they said. A wild guess? You have

an
exception killing your cache objects. You will need to do some old fashion debugging to figure this out. The problem most likely lies in your code.
Here is one place to begin. Remove all your catch blocks in your entire
application. In your application_error event, put script to display
Context.Error msg. Also, write a message to a static variable in your
session_end event in your global asax file. You need to see when the

session
is ending. It may be ending prematurely. Put a button on the form to read this static variable. Then test the page like you normally would. Any
exception will be displayed to the screen and you can go from there. I
figure you will have to debug on the server since the problem doesn't

occur
on your machine.
It aint no picnic though, but have fun on the way.

regards


Nov 18 '05 #8

P: n/a
Thanks for all your input on this.

Before contacting the hosting company at the site exhibiting the problem
with disappearing session variables with your suggestions, I contacted the
fellow who is allowing me to test my applications at the site where the
session variables do not disappear. Regarding your Application Pool
settings, he said the settings in question on his server are:

Recycle Tab: recycle worker processes every 1740 minutes.
Performance Tab: shut down work processes after being idle for 20 minutes &
limit the kernel request queue to 4000 requests.
Health Tab: enable pinging every 30 seconds & enable rapid-fail protection.

Given that the above settings work, does that point to other settings as
possible problems?
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2***************@tk2msftngp13.phx.gbl...
Ok, well have them make these setting adjustments:
From the application pool property pages in IIS, uncheck all settings under the Recycle tab (4)
From the Performance tab, uncheck the first two (Idle timeout and request
queue limit)
From the Health tab, uncheck Enable rapid-fail protection.

Let them know it is for debugging purposes because they might not be willing as these settings compromise the stability of the server. In addition, have them examine the idletimeout property in the machine config file to see what it is set to. The default is Infinite otherwise it is a time period
00:00:00.

regards

Nov 18 '05 #9

P: n/a
If these settings are the same on the faulty server/application, something
else is likely the issue.
At this point, I'm fresh out of ideas. I'd suggest you contact microsoft
about this so they can possibly take a memory dump and investigate further.
https://webresponse.one.microsoft.co...stedintro.aspx
you have 3 free requests you can make to microsoft if you originally
purchased the product which is the cause of the problem.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
Thanks for all your input on this.

Before contacting the hosting company at the site exhibiting the problem
with disappearing session variables with your suggestions, I contacted the
fellow who is allowing me to test my applications at the site where the
session variables do not disappear. Regarding your Application Pool
settings, he said the settings in question on his server are:

Recycle Tab: recycle worker processes every 1740 minutes.
Performance Tab: shut down work processes after being idle for 20 minutes & limit the kernel request queue to 4000 requests.
Health Tab: enable pinging every 30 seconds & enable rapid-fail protection.
Given that the above settings work, does that point to other settings as
possible problems?
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2***************@tk2msftngp13.phx.gbl...
Ok, well have them make these setting adjustments:
From the application pool property pages in IIS, uncheck all settings

under
the Recycle tab (4)
From the Performance tab, uncheck the first two (Idle timeout and request queue limit)
From the Health tab, uncheck Enable rapid-fail protection.

Let them know it is for debugging purposes because they might not be

willing
as these settings compromise the stability of the server. In addition,

have
them examine the idletimeout property in the machine config file to see

what
it is set to. The default is Infinite otherwise it is a time period
00:00:00.

regards


Nov 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.