views:

31

answers:

2

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 ?

A: 

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.

qbeuek
I'm only using the Session object. I mentionned Application object only because I tried to implement a pooling application (which was not successfull), since then I'm not using the Application object at all in this page, only Session object. I must clarify that only my local VBScript (ASP) variables gets mixed up. NOT my session variables
Jean Regis
That's impossible ;-) Either those are not plain VBScript local variables (provide a sample code) or you are misinterpreting some other bug as "mixing variables from different users" (elaborate on the effects seen or try to reproduce the bug on a small piece of code).
qbeuek
Added snippet as 2nd answer..
Jean Regis
A: 
<%@ 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
Jean Regis
v1, v2 and v3 are undeclared in this code, and it references the Log function, which is not declared here. Please provide a snippet that when run by you exactly as you paste it here, produces the result exactly pasted here (reproduce and verify it). The devil may be in the details.
qbeuek