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