为什么在IIS7中我的会话中对象会消失?

时间:2022-09-25 12:36:25

I'm making a series of calls to my web application (IIS7 in Classic mode). The first two calls instantiate objects and place them in the Session object.

我正在对我的web应用程序进行一系列调用(IIS7处于经典模式)。前两个调用实例化对象并将它们放在会话对象中。

By the time I make a third call, the session is missing an object. I expect there to be 2 of my keys in Session, but there is only 1.

当我进行第三次调用时,会话丢失了一个对象。我希望会话中有2把钥匙,但只有1把。

It's almost as though there are multiple sessions being created. One thing to note is that this happens a lot, it is not 100% repeatable, i.e. sometimes everything works fine.

就好像有多个会话被创建。需要注意的一件事是,这种情况经常发生,它不是100%可重复的,也就是说,有时候一切都很正常。

The objects are sizeable, but not huge (About 100 small strings) so it seems unlikely that I'm maxing out a session size. I'm not putting any other objects in there.

对象是相当大的,但不是很大的(大约100个小字符串),所以我不太可能将会话大小最大化。我不放其他物体进去。

3 个解决方案

#1


2  

Sounds like you are expieriencing an unhandled exception, that you are not aware of. The session gets destroyed upon such exceptions.

听起来好像你在为一个你没有意识到的未处理的异常赎罪。在这种例外情况下,会话将被销毁。

Set breakpoints in the global.asax to the Application_OnError, Session_End and Session_Start methods to check for them

在全局中设置断点。asax对Application_OnError、Session_End和Session_Start方法进行检查

#2


1  

Ok, I solved it (With the help of the global.asax tip from citronas).

好的,我在全球的帮助下解决了这个问题。从citronas asax提示)。

As ever, it turns out that I asserted things in my question and comments that were not as true as I'd assumed.

和以往一样,我在我的问题和评论中断言了一些不像我想象的那样真实的东西。

The first two calls are not actually made in serial, but the second was being made before the first had had time to return. This resulted in two Session_Start calls (Interestingly with the same session ID). The first session data was therefore being overwritten.

前两个调用实际上不是串行的,但是第二个调用是在第一个调用返回之前发出的。这导致了两个Session_Start调用(有趣的是使用相同的会话ID)。因此,第一个会话数据被覆盖。

Changing my app to wait for each call to return fixed the problem.

改变我的应用,等待每一个电话的返回修复了问题。

Thanks to everyone who answered or commented.

感谢所有回复或评论的人。

#3


0  

Which one disappeared, the first or the latest added? Your application seems to be recycled after the first call, so the first added will be erased.

哪个消失了,第一个还是最新的?您的应用程序似乎在第一次调用之后被回收,所以第一次添加的应用程序将被删除。

#1


2  

Sounds like you are expieriencing an unhandled exception, that you are not aware of. The session gets destroyed upon such exceptions.

听起来好像你在为一个你没有意识到的未处理的异常赎罪。在这种例外情况下,会话将被销毁。

Set breakpoints in the global.asax to the Application_OnError, Session_End and Session_Start methods to check for them

在全局中设置断点。asax对Application_OnError、Session_End和Session_Start方法进行检查

#2


1  

Ok, I solved it (With the help of the global.asax tip from citronas).

好的,我在全球的帮助下解决了这个问题。从citronas asax提示)。

As ever, it turns out that I asserted things in my question and comments that were not as true as I'd assumed.

和以往一样,我在我的问题和评论中断言了一些不像我想象的那样真实的东西。

The first two calls are not actually made in serial, but the second was being made before the first had had time to return. This resulted in two Session_Start calls (Interestingly with the same session ID). The first session data was therefore being overwritten.

前两个调用实际上不是串行的,但是第二个调用是在第一个调用返回之前发出的。这导致了两个Session_Start调用(有趣的是使用相同的会话ID)。因此,第一个会话数据被覆盖。

Changing my app to wait for each call to return fixed the problem.

改变我的应用,等待每一个电话的返回修复了问题。

Thanks to everyone who answered or commented.

感谢所有回复或评论的人。

#3


0  

Which one disappeared, the first or the latest added? Your application seems to be recycled after the first call, so the first added will be erased.

哪个消失了,第一个还是最新的?您的应用程序似乎在第一次调用之后被回收,所以第一次添加的应用程序将被删除。