global.asa 中的经典 asp 错误:需要对象:'Session'
Windows 2003 计算机上的服务器端 VB asp 代码,安装了 asp.net 2.0*。我们遇到一个奇怪的问题,即用户第一次连接到网站时,Global.asa 中的 Session_OnStart 会触发,但会话对象为空。像这样简单的事情
Session.Timeout = 30
会导致以下错误: 需要对象:“会话”
该网站已在 IIS 管理器主目录选项卡中“创建”,并且在该站点的配置页面中启用了会话。
大多数情况下,如果用户刷新页面,会话对象就会存在。但唯一用户的首次访问总是会导致错误。
建议?该代码没有错误,因为它在旧的Win2000系统上运行。
重申一下:Windows 2003 Server,运行 IIS6,安装了 .Net 2.0。网站作为应用程序运行,而不是虚拟目录。
Server side VB asp code on a Windows 2003 machine, asp.net 2.0* installed. We're having a weird issue where the first time a user connects to the web site, the Session_OnStart in the Global.asa fires, but the session object is null. Something simple like:
Session.Timeout = 30
causes the following error: Object required: 'Session'
The web site has been 'created' in the IIS Manager Home Directory tab, and Sessions are enabled in the Configuration page for the site.
In most cases, the session object exists if the user refreshes the page. But that first visit for a unique user always causes the error.
Suggestions? The code doesn't have an error, as it worked on the old Win2000 system.
Just to reiterate: Windows 2003 Server, running IIS6, with .Net 2.0 installed. Web site is running as an application, not a virtual directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找出问题所在了。这是因为应用程序池中有不止一名工作人员用于该网站。由于无法保证哪个工作进程将处理客户端的请求,并且每个工作进程都会创建自己的客户端会话实例,因此当 IIS 决定由不同的工作进程处理请求时,会话将被删除并重新创建。通过仅使用应用程序池中的一个工作进程,并将所有其他网站从应用程序池中取出并放入自己的应用程序池中,问题得到了解决。
我现在正在寻找一种方法,让应用程序池中有多个工作人员,但让客户端坚持工作进程。但这是我要研究的另一个问题。
Figured out the problem. It was due to having more than one worker in the app pool used for the website. Since there was no guarantee which worker process would handle a client's request, and each worker process would create it's own instance of the client's session, the session would be dropped and recreated when IIS decided that a different worker process should handle a request. Problem was resolved by using only one worker process in the app pool, and getting all the other websites out of the app pool and into their own.
I'm now looking for a way to have multiple workers in the app pool but to have the client stick with the worker process. But that's a different problem that I'll research.
相当有趣的问题。
我们知道,当会话被明确放弃或最终超时时,它会立即被销毁。我会添加如下代码,以保证它不会发生。
您还可以在此块中调用创建对象的代码;这样,如果您检测到会话被某种方式破坏,您可以重新创建它们。
Quite an interesting problem.
We know that when the session is explicitly abandoned or eventually times out it is promptly destroyed. I would add code like the following, in order to guarantee it cannot happen.
You could also call the code that creates your objects in this block; this way, if you detect that the session was somehow destroyed, you could recreate them.