不同用户的经典 ASP 同时调用

发布于 2024-09-24 01:48:49 字数 402 浏览 6 评论 0原文

我有这个经典的 ASP Web 应用程序。每个用户都必须登录,并且他们最重要的数据保存在会话变量中。后端是MS-SQL。

当用户提交到特定页面时,该页面会执行很多操作,包括创建文件和访问数据库,因此每个请求最多可能需要 2-3 秒才能执行。

我的问题是:当用户提交到此页面时,在等待时,如果另一个用户提交到同一页面,则两个请求会同时执行,并且我的 VBScript 变量会混淆。换句话说,IIS(?)不会等待第一个请求完成才发送第二个请求。

我尝试使用 Application 对象实现某种池化,但失败得很惨。我需要能够一一威胁每个用户。第二个用户是否等待第一个用户并不重要。

在这种特殊情况下,我使用的是 IIS6,并且我的所有 asp 页面都分配给自定义应用程序池,该池的工作进程设置为 1(我不确定这是否会改变任何内容?

I have this classic ASP web application. Each user must login and their most important data are kept in Session variables. Back-end is MS-SQL.

When user submit to a particular page, this ones does a lot of stuff including creating files and accessing the database, so each request can take up to 2-3 seconds to perform.

Here's my problem: When a user submit to this page, while he waits, if another user submit to the same page, both requests are then performed simultaneously and my VBScript variables gets mixed up. In other word, IIS (?) does not wait for the first request to be completed before sending the second one.

I tried implementing some kind of pooling using the Application object but it failed miserably. I need to be able to threat every user on a one-by-one basis. It does not matter if the second user waits for the first one.

In this particular case I'm using IIS6 and all my asp page are assigned to a custom Application Pool, worker process of this pool is set to 1 (I'm not sure if that changes anything ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

GRAY°灰色天空 2024-10-01 01:48:49

如果将会话变量保存在 Session 对象中,一切都应该没问题。

另一方面,如果您将会话变量保存在 Application 对象中,则多个同时请求共享变量,并且如果没有同步,一切都会崩溃。

您在哪里存储会话变量?提供代码片段。

If you keep your session variables in a Session object, everything should be OK.

If on the other hand you keep your session variables in an Application object, the multiple simultaneus requests share variables and without synchronization all hell breaks loose.

Where do you store your session variables? Provide a code snippet.

×眷恋的温暖 2024-10-01 01:48:49
<%@ Language=VBScript %>
<%
Option Explicit

Dim localvar

'The Log function append a string to a local file on server'
Log cStr(Now()) & " " Session.SessionID & " - debug 1"

'Function 1 takes 2 seconds RETURNS abc'
v1 = DoCrazyStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 2 " & localvar

'Function 2 takes 2 seconds RETURNS def'
v2 = DoOtherStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 3 " & localvar

'Function 3 takes 2 seconds RETURNS ghi'
v3 = DoYetMoreStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 4 " & localvar

%>

然后日志将显示

10:00:00 PM 111111111 debug 1
10:00:02 PM 111111111 debug 2 abc
10:00:04 PM 111111111 debug 3 def
10:00:04 PM 222222222 debug 1
10:00:06 PM 111111111 debug 4 ghi
10:00:06 PM 222222222 debug 2 ghi
<%@ Language=VBScript %>
<%
Option Explicit

Dim localvar

'The Log function append a string to a local file on server'
Log cStr(Now()) & " " Session.SessionID & " - debug 1"

'Function 1 takes 2 seconds RETURNS abc'
v1 = DoCrazyStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 2 " & localvar

'Function 2 takes 2 seconds RETURNS def'
v2 = DoOtherStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 3 " & localvar

'Function 3 takes 2 seconds RETURNS ghi'
v3 = DoYetMoreStuff()

Log cStr(Now()) & " " Session.SessionID & " - debug 4 " & localvar

%>

The log would then show

10:00:00 PM 111111111 debug 1
10:00:02 PM 111111111 debug 2 abc
10:00:04 PM 111111111 debug 3 def
10:00:04 PM 222222222 debug 1
10:00:06 PM 111111111 debug 4 ghi
10:00:06 PM 222222222 debug 2 ghi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文