Yes ... yet another question about Session State!! - Long

M

Martin

Hi all

As my posting title suggests I'm having problems using InProc Session
state in my ASP .NET app.

I wrote a site for a friend which uses ADO .NET to keep track of a
simple customer/purchases database. A user creates an account and a
database entry is added to a customer table. Once a user successfully
logs in with a valid Username/Password I store away the UserID (which
is the primary key of the Customers table) in the Session object, and
use this across the app to reference data for display.

Everything worked perfectly on my server at home : XP Pro, IIS 5.1
however as soon as i uploaded everything to my host (oneandone.co.uk)
I began to see intermittent Session state fall out. I was testing for
Session["UserID"] = null and moving user to a default login page (set
in web.config) if this was true, the idea being to stop people
navigating directly to a page without first logging in. This began to
happen 'randomly' whilst a user was validly logged in. This has
nothing to do with the timing out of Session. This is set to 100 mins
in my config file and session sometimes falls out on the first page
move after valid login.

The only consistent clue that I can report is that the Nulling of my
Session object always seems to happen when a refresh of a page is NOT
instant but when there is some server delay. You know ... you hit F5
and the server is slow to respond. When this happens I always know
that Session will be null when page comes back. Maybe this is the key.
But I don't know the reason.

Because the site was effectively broken with this behaviour, and the
system was 'live' I quickly had to tear everything down and recode the
solution using Query Strings in the urls. Very combersome, but the
site now works.

Now the dust has settled I want to find out why the Session state was
'broken'.
I believe oneandone use Windows Server 2003 with IIS 6.0. They have
only very recently started to offer ASP .NET and I suspect they may
have set something up incorrectly (of course it could be something
i've done wrong LOL)

I found the following Knowledge Base articles that point to possible
answers :
http://support.microsoft.com/default.aspx?scid=kb;EN-US;316148
http://support.microsoft.com/default.aspx?scid=kb;en-us;324772

The first of these provides some sample code to test for Session State
fallout and I have uploaded this to my host and indeed I get the same
intermittent 'fallout' as I did with my own code.

The second of these suggests that the problem could be caused by,
"Virus scanning software touched some .config files" and goes on to
say, "This is why the session state is lost when Aspnet_wp.exe (or
W3wp.exe, for applications that run on Microsoft Internet Information
Services [IIS] 6.0) or the AppDomain restarts."

I cannot believe Anti-Virus software on my host can be causing the
problem, as if this was the case they (and this newsgroup, I'm sure)
would have been inundated with queries, however, I need to eliminate
this cause from the equation. I shall mail their support team and ask
them specifically about the Anti-Virus issue, but I was wondering if
there was something I could do in code (C# preferably) that could test
explicitly for W3wp.exe restarting.

Thinking about it, maybe the server sluggishness just before session
goes null, that I reported earlier, was this .exe restarting!! ??

Apologies for the length of the post and thank you to those of you who
have stuck with it :) I look forward to your suggestions for a way
forward, or any comments on similar experiences.

Thank you for listening.

Kind Regards,

Martin
 
P

PJ

The asp.net process may recycle itself and cause you to lose session if the
process takes a certain % of system memory as defined in the
machine.confiig. There are plenty of articles on how to monitor this.

I'm not sure about w2k3, but I'm sure the asp appliation start event will
run everytime the w3wp.exe restarts, so you could simply log the time to the
file everytime this happens.

Martin said:
Hi all

As my posting title suggests I'm having problems using InProc Session
state in my ASP .NET app.

I wrote a site for a friend which uses ADO .NET to keep track of a
simple customer/purchases database. A user creates an account and a
database entry is added to a customer table. Once a user successfully
logs in with a valid Username/Password I store away the UserID (which
is the primary key of the Customers table) in the Session object, and
use this across the app to reference data for display.

Everything worked perfectly on my server at home : XP Pro, IIS 5.1
however as soon as i uploaded everything to my host (oneandone.co.uk)
I began to see intermittent Session state fall out. I was testing for
Session["UserID"] = null and moving user to a default login page (set
in web.config) if this was true, the idea being to stop people
navigating directly to a page without first logging in. This began to
happen 'randomly' whilst a user was validly logged in. This has
nothing to do with the timing out of Session. This is set to 100 mins
in my config file and session sometimes falls out on the first page
move after valid login.

The only consistent clue that I can report is that the Nulling of my
Session object always seems to happen when a refresh of a page is NOT
instant but when there is some server delay. You know ... you hit F5
and the server is slow to respond. When this happens I always know
that Session will be null when page comes back. Maybe this is the key.
But I don't know the reason.

Because the site was effectively broken with this behaviour, and the
system was 'live' I quickly had to tear everything down and recode the
solution using Query Strings in the urls. Very combersome, but the
site now works.

Now the dust has settled I want to find out why the Session state was
'broken'.
I believe oneandone use Windows Server 2003 with IIS 6.0. They have
only very recently started to offer ASP .NET and I suspect they may
have set something up incorrectly (of course it could be something
i've done wrong LOL)

I found the following Knowledge Base articles that point to possible
answers :
http://support.microsoft.com/default.aspx?scid=kb;EN-US;316148
http://support.microsoft.com/default.aspx?scid=kb;en-us;324772

The first of these provides some sample code to test for Session State
fallout and I have uploaded this to my host and indeed I get the same
intermittent 'fallout' as I did with my own code.

The second of these suggests that the problem could be caused by,
"Virus scanning software touched some .config files" and goes on to
say, "This is why the session state is lost when Aspnet_wp.exe (or
W3wp.exe, for applications that run on Microsoft Internet Information
Services [IIS] 6.0) or the AppDomain restarts."

I cannot believe Anti-Virus software on my host can be causing the
problem, as if this was the case they (and this newsgroup, I'm sure)
would have been inundated with queries, however, I need to eliminate
this cause from the equation. I shall mail their support team and ask
them specifically about the Anti-Virus issue, but I was wondering if
there was something I could do in code (C# preferably) that could test
explicitly for W3wp.exe restarting.

Thinking about it, maybe the server sluggishness just before session
goes null, that I reported earlier, was this .exe restarting!! ??

Apologies for the length of the post and thank you to those of you who
have stuck with it :) I look forward to your suggestions for a way
forward, or any comments on similar experiences.

Thank you for listening.

Kind Regards,

Martin
 
K

Kevin Spencer

Hi Martin,

Didn't you say at the beginning of your message that this host has "only
very recently" started to support ASP.Net? If so, why would anyone be
"inundated with queries" about their use of virus protection software? You
found a Knowledge Base article. That means that this problem has occurred
and been reported enough times to Microsoft to write a KB article about it.
Virus protection software has been responsible for many a problem. It's a
simple matter of a phone call or email to confirm it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.

Martin said:
Hi all

As my posting title suggests I'm having problems using InProc Session
state in my ASP .NET app.

I wrote a site for a friend which uses ADO .NET to keep track of a
simple customer/purchases database. A user creates an account and a
database entry is added to a customer table. Once a user successfully
logs in with a valid Username/Password I store away the UserID (which
is the primary key of the Customers table) in the Session object, and
use this across the app to reference data for display.

Everything worked perfectly on my server at home : XP Pro, IIS 5.1
however as soon as i uploaded everything to my host (oneandone.co.uk)
I began to see intermittent Session state fall out. I was testing for
Session["UserID"] = null and moving user to a default login page (set
in web.config) if this was true, the idea being to stop people
navigating directly to a page without first logging in. This began to
happen 'randomly' whilst a user was validly logged in. This has
nothing to do with the timing out of Session. This is set to 100 mins
in my config file and session sometimes falls out on the first page
move after valid login.

The only consistent clue that I can report is that the Nulling of my
Session object always seems to happen when a refresh of a page is NOT
instant but when there is some server delay. You know ... you hit F5
and the server is slow to respond. When this happens I always know
that Session will be null when page comes back. Maybe this is the key.
But I don't know the reason.

Because the site was effectively broken with this behaviour, and the
system was 'live' I quickly had to tear everything down and recode the
solution using Query Strings in the urls. Very combersome, but the
site now works.

Now the dust has settled I want to find out why the Session state was
'broken'.
I believe oneandone use Windows Server 2003 with IIS 6.0. They have
only very recently started to offer ASP .NET and I suspect they may
have set something up incorrectly (of course it could be something
i've done wrong LOL)

I found the following Knowledge Base articles that point to possible
answers :
http://support.microsoft.com/default.aspx?scid=kb;EN-US;316148
http://support.microsoft.com/default.aspx?scid=kb;en-us;324772

The first of these provides some sample code to test for Session State
fallout and I have uploaded this to my host and indeed I get the same
intermittent 'fallout' as I did with my own code.

The second of these suggests that the problem could be caused by,
"Virus scanning software touched some .config files" and goes on to
say, "This is why the session state is lost when Aspnet_wp.exe (or
W3wp.exe, for applications that run on Microsoft Internet Information
Services [IIS] 6.0) or the AppDomain restarts."

I cannot believe Anti-Virus software on my host can be causing the
problem, as if this was the case they (and this newsgroup, I'm sure)
would have been inundated with queries, however, I need to eliminate
this cause from the equation. I shall mail their support team and ask
them specifically about the Anti-Virus issue, but I was wondering if
there was something I could do in code (C# preferably) that could test
explicitly for W3wp.exe restarting.

Thinking about it, maybe the server sluggishness just before session
goes null, that I reported earlier, was this .exe restarting!! ??

Apologies for the length of the post and thank you to those of you who
have stuck with it :) I look forward to your suggestions for a way
forward, or any comments on similar experiences.

Thank you for listening.

Kind Regards,

Martin
 
M

Martin

Kevin

Point taken. I will definately give the help line a ring. That is the
next time I feel like waiting in a queue for half an hour ;)

Martin
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top