473,289 Members | 1,952 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,289 software developers and data experts.

Disappearing Sessions

Hi,

I'm presently converting a v1.1 ASP.NET app to v2, and am encountering a
strange problem.

When running in Debug mode (i.e. hitting F5), all is well.

However, when running without debugging (i.e. hitting Ctrl-F5), every so
often (it seems to be totally random) the entire Session seems to get torn
down causing Session_Start to fire again, thereby losing any Session
variables which have been created. This, in turn, causes the standard
"Object reference not set to an instance of an object" error because the
Session object which the code is expecting is not there.

Also, strangely, the Error Source for the above errors is always slightly
different e.g.

App_Web_zsxmxts_
App_Web_oxwoppmb
App_Web_82ilyo2x
App_Web_5iwdsnnv
App_Web_5iwdsnnv
App_Web_sog3df_f

I found the following article: http://forums.asp.net/thread/1271201.aspx but
the MS HotFix it refers to doesn't seem to have anything do do with my
current problem.

Has anyone seen anything like this before? I must have converted a dozen or
so v1.1 apps to v2 by now, and I've never encountered anything remotely
similar...

Any assistance gratefully received.

Mark
May 15 '06 #1
15 3961
Hi

The only thing I've seen similar is when a runtime error occurs in the
ASP.NET application, causing the application to restart. Are you receiving
Application_OnStart events too? Have you got anything that could be hiding an
error (e.g. an Application_Error handler)

Cheers

Wayne

"Mark Rae" wrote:
Hi,

I'm presently converting a v1.1 ASP.NET app to v2, and am encountering a
strange problem.

When running in Debug mode (i.e. hitting F5), all is well.

However, when running without debugging (i.e. hitting Ctrl-F5), every so
often (it seems to be totally random) the entire Session seems to get torn
down causing Session_Start to fire again, thereby losing any Session
variables which have been created. This, in turn, causes the standard
"Object reference not set to an instance of an object" error because the
Session object which the code is expecting is not there.

Also, strangely, the Error Source for the above errors is always slightly
different e.g.

App_Web_zsxmxts_
App_Web_oxwoppmb
App_Web_82ilyo2x
App_Web_5iwdsnnv
App_Web_5iwdsnnv
App_Web_sog3df_f

I found the following article: http://forums.asp.net/thread/1271201.aspx but
the MS HotFix it refers to doesn't seem to have anything do do with my
current problem.

Has anyone seen anything like this before? I must have converted a dozen or
so v1.1 apps to v2 by now, and I've never encountered anything remotely
similar...

Any assistance gratefully received.

Mark

May 15 '06 #2
"WayneB" <Wa****@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...

Wayne,
The only thing I've seen similar is when a runtime error occurs in the
ASP.NET application, causing the application to restart. Are you receiving
Application_OnStart events too? Have you got anything that could be hiding
an
error (e.g. an Application_Error handler)


That's interesting - I don't *think* I'm getting Application_OnStart events,
but what you're saying certainly sounds possible.

The app does indeed have an Application_Error handler, but it's a fairly
standard one from what I can see - as part of my testing the upgrade, I've
obviously deliberately forced an unhandled error, and the Application_Error
handler certainly does seem to handle it cleanly enough, i.e. redirects to
an error.aspx page, displays a friendly message to the user, and emails
details of the error to the webmaster...

However, I'll disable that temporarily and see what I find.

Thanks for the reply.

Mark
May 15 '06 #3
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:uy**************@TK2MSFTNGP02.phx.gbl...
However, I'll disable that temporarily and see what I find.


A trawl round Google turned up this site:
http://west-wind.com/weblog/posts/4057.aspx which mentions a "similar"
problem of Sessions disappearing when moving between http and https.
Initially, I thought I was onto something because the app I'm working on
does do that, but it uses Matt Sollars' excellent HttpModule for this
(http://www.codeproject.com/aspnet/We...curity_v2.asp), which works
perfectly inasmuch as I'm able to switch between secure and unsecure pages
without affecting the Session collection, so I'm pretty sure that's not the
problem. In fact, I even tried removing that HttpModule entirely from the
app, and the problem didn't go away...

So, I disabled the Application_Error code and, temporarily, even removed all
try..catch statements from the code. The problem (i.e. the disappearing
Session) still occurs, but I'm still no closer to finding out why. Thus far,
I can say:

1) the Session is getting torn down and rebuilt at random intervals

2) the Application is not getting recylced

3) the tearing down of the Session "appears" not to be being caused by an
unhandled exception

Incidentally, forgive my ignorance, but is there a "Break on all errors"
equivalent in VS.NET 2005, specifically for ASP.NET / C#...? In v1.1, there
was a Debug, Exceptions window where you could do something similar...

May 15 '06 #4
Hi Mark

Have you tried Debug->Exceptions, check the Thrown boxes.

To try and find the cause of the problem, I would add logging the session
and application events in global.asax. Session_Start, Session_End,
Application_Start, Application_End, Application_Error. I'd also put
breakpoints on them and run the pages in debug mode that way it might help to
narrow down when exactly the problem is occurring

Cheers

Wayne

"Mark Rae" wrote:
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:uy**************@TK2MSFTNGP02.phx.gbl...
However, I'll disable that temporarily and see what I find.


A trawl round Google turned up this site:
http://west-wind.com/weblog/posts/4057.aspx which mentions a "similar"
problem of Sessions disappearing when moving between http and https.
Initially, I thought I was onto something because the app I'm working on
does do that, but it uses Matt Sollars' excellent HttpModule for this
(http://www.codeproject.com/aspnet/We...curity_v2.asp), which works
perfectly inasmuch as I'm able to switch between secure and unsecure pages
without affecting the Session collection, so I'm pretty sure that's not the
problem. In fact, I even tried removing that HttpModule entirely from the
app, and the problem didn't go away...

So, I disabled the Application_Error code and, temporarily, even removed all
try..catch statements from the code. The problem (i.e. the disappearing
Session) still occurs, but I'm still no closer to finding out why. Thus far,
I can say:

1) the Session is getting torn down and rebuilt at random intervals

2) the Application is not getting recylced

3) the tearing down of the Session "appears" not to be being caused by an
unhandled exception

Incidentally, forgive my ignorance, but is there a "Break on all errors"
equivalent in VS.NET 2005, specifically for ASP.NET / C#...? In v1.1, there
was a Debug, Exceptions window where you could do something similar...

May 16 '06 #5
"WayneB" <Wa****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
Have you tried Debug->Exceptions, check the Thrown boxes.
I would if I could... that opion doesn't appear under my Debug menu. FYI,
the options I have are:

Windows
--------------------
Continue
Break All
Stop debugging
Detach All
Terminate All
Restart
Attach to Process
--------------------
Step Over
--------------------
Toggle Breakpoint
Delete All Breakpoints
To try and find the cause of the problem, I would add logging the session
and application events in global.asax. Session_Start, Session_End,
Application_Start, Application_End, Application_Error.
I've done that.
I'd also put breakpoints on them and run the pages in debug mode that way
it might help to narrow down when exactly the problem is occurring


As I mentioned in my original post, the problem doesn't occur in debug mode.
May 16 '06 #6
"WayneB" <Wa****@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...

Wayne,
Have you tried Debug->Exceptions, check the Thrown boxes.
Yes - finally found that dialog (!) and have set it to break every time an
error is thrown. No errors appear to being thrown before the Session
disappears.
To try and find the cause of the problem, I would add logging the session
and application events in global.asax. Session_Start, Session_End,
Application_Start, Application_End, Application_Error.
Done that - all that has shown is that Sessio_End is being fired at random
moments - there appears to be neither pattern nor logic to it.
I'd also put breakpoints on them and run the pages in debug mode that way
it might help to
narrow down when exactly the problem is occurring
Again, done that - there is nothing to indicate why Session_End is being
fired. When the code reaches the breakpoint I've set in Session_End, the
Stack window displays slight variations on the following each time...
App_Code.jpjgc0sh.dll!Global.Session_End(object sender =
{System.Web.SessionState.SessionOnEndTarget}, System.EventArgs e =
{System.EventArgs}) Line 61 C#

[Frames below may be incorrect and/or missing, no symbols loaded for
mscorwks.dll]
System.Web.dll!System.Web.HttpApplication.ProcessS pecialRequest(System.Web.HttpContext
context = null, System.Reflection.MethodInfo method, int paramCount, object
eventSource, System.EventArgs eventArgs,
System.Web.SessionState.HttpSessionState session) + 0xe4 bytes
System.Web.dll!System.Web.HttpApplicationFactory.F ireSessionOnEnd(System.Web.SessionState.HttpSessio nState
session, object eventSource, System.EventArgs eventArgs) + 0xb9 bytes
System.Web.dll!System.Web.SessionState.SessionOnEn dTarget.RaiseSessionOnEnd(string
id, System.Web.SessionState.SessionStateStoreData item) + 0x101 bytes
System.Web.dll!System.Web.SessionState.InProcSessi onStateStore.OnCacheItemRemoved(string
key, object value, System.Web.Caching.CacheItemRemovedReason reason) + 0x120
bytes
System.Web.dll!System.Web.Caching.CacheEntry.CallC acheItemRemovedCallback(System.Web.Caching.CacheIt emRemovedCallback
callback, System.Web.Caching.CacheItemRemovedReason reason) + 0xef bytes
System.Web.dll!System.Web.Caching.CacheEntry.Close (System.Web.Caching.CacheItemRemovedReason
reason) + 0x1c5 bytes
System.Web.dll!System.Web.Caching.CacheSingle.Upda teCache(System.Web.Caching.CacheKey
cacheKey, System.Web.Caching.CacheEntry newEntry = null, bool replace,
System.Web.Caching.CacheItemRemovedReason removedReason, out object
valueOld) + 0x98c bytes
System.Web.dll!System.Web.Caching.CacheInternal.Do Remove(System.Web.Caching.CacheKey
cacheKey, System.Web.Caching.CacheItemRemovedReason reason) + 0x18 bytes
System.Web.dll!System.Web.Caching.CacheSingle.Disp ose(bool disposing =
true) + 0x198 bytes
System.Web.dll!System.Web.Caching.CacheMultiple.Di spose(bool disposing =
true) + 0x46 bytes
System.Web.dll!System.Web.HttpRuntime.Dispose() + 0xd5 bytes
System.Web.dll!System.Web.HttpRuntime.ReleaseResou rcesAndUnloadAppDomain(object
state) + 0x6a bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallb ack.WaitCallback_Context(object
state) + 0x2f bytes
mscorlib.dll!System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext
executionContext, System.Threading.ContextCallback callback, object state) +
0x81 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallb ack.PerformWaitCallback(object
state) + 0x6c bytes
[Appdomain Transition]

I don't know enough about the internals of the Framework to glean very much
from this, but it is clear that something somewhere is causing
Global.Session_End to fire...

I'm really out of options now, so I'm thinking all I can do is to create a
new web app from the ground up and add the pages in one by one to see if
that fixes it...

Mark
May 17 '06 #7
>
Done that - all that has shown is that Sessio_End is being fired at random
moments - there appears to be neither pattern nor logic to it.


Did you check the SessionID for the session whose Session_End was fired
to see that it was *your* session ending?
The breakpoint will be hit on *any* execution of that code, so you
might be seeing the regular end of previous sessions (by default 20
minutes after the last request in that session)

A hint: if you change web.config (even if you add/remove just a space)
then the application will reset, so any previous sessions will be
cancelled.

Hans Kesting
May 17 '06 #8
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:mn***********************@spamgourmet.com...
Done that - all that has shown is that Sessio_End is being fired at
random moments - there appears to be neither pattern nor logic to it.

Did you check the SessionID for the session whose Session_End was fired
to see that it was *your* session ending?


Yes.
The breakpoint will be hit on *any* execution of that code, so you
might be seeing the regular end of previous sessions (by default 20
minutes after the last request in that session)
Fair comment, though even if it was another session ending (it wasn't) it
shouldn't tear down *my* session, right...?
A hint: if you change web.config (even if you add/remove just a space)
then the application will reset, so any previous sessions will be
cancelled.


I'm not changing web.config anywhere.
May 17 '06 #9
Do you see any entries in the event log for application pool recycling? Or
anything out of place?

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:uw**************@TK2MSFTNGP05.phx.gbl...
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:mn***********************@spamgourmet.com...
Done that - all that has shown is that Sessio_End is being fired at
random moments - there appears to be neither pattern nor logic to it.


Did you check the SessionID for the session whose Session_End was fired
to see that it was *your* session ending?


Yes.
The breakpoint will be hit on *any* execution of that code, so you
might be seeing the regular end of previous sessions (by default 20
minutes after the last request in that session)


Fair comment, though even if it was another session ending (it wasn't) it
shouldn't tear down *my* session, right...?
A hint: if you change web.config (even if you add/remove just a space)
then the application will reset, so any previous sessions will be
cancelled.


I'm not changing web.config anywhere.

May 17 '06 #10
"Alvin Bruney" <www.lulu.com/owc> wrote in message
news:uG**************@TK2MSFTNGP02.phx.gbl...
Do you see any entries in the event log for application pool recycling? Or
anything out of place?


Nope...
May 17 '06 #11
> "Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:mn***********************@spamgourmet.com...
Done that - all that has shown is that Sessio_End is being fired at random
moments - there appears to be neither pattern nor logic to it.


Did you check the SessionID for the session whose Session_End was fired
to see that it was *your* session ending?


Yes.
The breakpoint will be hit on *any* execution of that code, so you
might be seeing the regular end of previous sessions (by default 20 minutes
after the last request in that session)


Fair comment, though even if it was another session ending (it wasn't) it
shouldn't tear down *my* session, right...?


No, it shouldn't
A hint: if you change web.config (even if you add/remove just a space)
then the application will reset, so any previous sessions will be
cancelled.


I'm not changing web.config anywhere.


Sorry, the remark wasn't clear enough. What I meant was that by
recycling the application on purpose, you are sure that there are no
"other sessions" troubling you. (but that was not the case)

Hans Kesting
May 17 '06 #12
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:mn***********************@spamgourmet.com...
A hint: if you change web.config (even if you add/remove just a space)
then the application will reset, so any previous sessions will be
cancelled.


I'm not changing web.config anywhere.


Sorry, the remark wasn't clear enough. What I meant was that by recycling
the application on purpose, you are sure that there are no "other
sessions" troubling you. (but that was not the case)


Ah - I'm periodically running iisreset for precisely this purpose...
May 17 '06 #13
JDP
Has there been any resolution to why the sessions would just disappear, for no reason. I'm having this issue with a few client. It seems like for no reason the session is gone and the website dies.
May 26 '06 #14
JDP, Here is a post of mine from another thread. Hope this helps.
I've implemented code to detect timeouts now in an app that was giving
me problems. It seems to be working fine now. I added a redirect to a
"session expired" page which has a link to log back on (I have it
dropping the auth cookie when the session times out) I recommend
setting your auth timeout to a value at least twice as long as the
session timeout just to be safe. Here is my previous post.

I have seen this happen before. It could be that your session actually
is timing out. There is a session timeout and an authentication
timeout. The fact that you are not redirected to the login page does
not prove that your session has not timed out.

Here is a good site with info on detecting a session timeout:

http://aspalliance.com/520

Not Me wrote:
Göran Andersson wrote:
> Not Me wrote:
>> I have a set of pages that use forms authentication for access. There >> are times when one of the session objects I'm using appears to
>> disappear. The session is not timing out, however. (if I go to a page >> that doesn't use that specific object it works fine and I'm not
>> redirected to the login page) >> Could it be that the object is being 'cleaned up' at arbitrary times
>> due to it not being accessed? or should it stay where it is once it's
>> been assigned to the session (at least until the session expires)?
The session object is the one you reference using the name Session.
When you store your object you are using a session variable.
A session object is never partially timed out. When a session times out all session variables are lost.
If only one of the session variables gets lost, the most likely

reason is that you are actually removing it somewhere in your code.
Thanks for the confirmation.. looks like I'll have to debug a bit further.. it certainly only happens very occasionally
cheers,
JDP wrote: Has there been any resolution to why the sessions would just disappear, for no reason. I'm having this issue with a few client. It seems like for no reason the session is gone and the website dies.

May 27 '06 #15
Session lost.
when..
- Various attributes (for example, the memoryLimit attribute) have
particular settings in the <processModel> section of the configuration
file.
- The Global.asax or the Web.config file was modified.
- The Bin directory of the Web application was modified.
- Virus scanning software touched some .config files
When you use F5 es WORLD PEFECT :)

(textual solution for msdn) ...
To work around this problem, you can use StateServer or SqlServer
session state mode. ASP.NET provides these other approaches for storing
session state data. In the StateServer and SqlServer modes, your
session state is not stored in the AppDomain of the Web application

It work.! and my solution

I implemented State Server Mode
To use State Server, you must first make sure ASP.NET state service is
running on the remote server used for the session store. This service
is installed with ASP.NET and Visual Studio .NET at the following
location:

systemroot\Microsoft.NET\Framework\versionNumber\a spnet_state.exe

Next, set the mode attribute of the <sessionState> element to
StateServer in the Web.config file of the application. Finally, set the
connectionString attribute to tcpip=serverName:portNumber.
Try this example with STATE SERVER MODE in your webapp

(Link)
Session Data Is Lost When You Use ASP.NET InProc Session State Mode
http://support.microsoft.com/default...b;en-us;324772

Session State
http://msdn.microsoft.com/library/de...ssionstate.asp

Best Practices
Fast, Scalable, and Secure Session State Management for Your Web
Applications
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

Why is my ASP.NET application restarting?
http://support.microsoft.com/kb/871042/en-us

May 27 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background...
7
by: DartmanX | last post by:
I have created a wizard which walks a user through a process of selecting data to be generated into an XML file. Each page adds its own data to $_SESSION, until the final page. On this page, an...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.