Session Variables getting cross threaded

R

Randy

Hello,
I'm having a strange problem. I've got a .NET web app which uses Session
variables. Sometime, not all the time, they get cross threaded...that
is...one user will have another user's Session variable(s) data assigned to
them. I can't figure out why. I've read that other people are having this
problem too but I haven't found a resolution yet. Can someone please tell me
how I might go about fixing this?

Thanks
 
C

Christoph Wienands

Hey Randy,

Randy said:
Hello,
I'm having a strange problem. I've got a .NET web app which uses Session
variables. Sometime, not all the time, they get cross threaded...that
is...one user will have another user's Session variable(s) data assigned
to them. I can't figure out why. I've read that other people are having
this problem too but I haven't found a resolution yet. Can someone please
tell me how I might go about fixing this?

What's the environment? OS, IIS, etc...
 
R

Randy

Sorry, the app is using .NET v1.1.4322, the OS on the server is Server
2003...so I think the IIS version would be 6?
I'm wondering if it might be caused by using static variables?
Thanks for your help
 
R

Randy

In particular...what is happening is...say two users are logged in. There is
a dropdown listbox which contains paypools. If the user changes paypools,
then the Session["paypool"] for that user is set to this. There are several
buttons on this page which go to different pages. One goes to a screen which
uses the Session["paypool"] object in a query (to Oracle) to populate this
new page. If both users click this button very close to the same time, the
second user will get the Session["paypool"] object of the other user.
 
B

Bruce Barker

this is almost always a bug in the asp.net code. most likely you are storing
a reference to a session variable in vb module (shared). this is a no, no,
as vb module variables are shared across threads.

-- bruce (sqlwork.com)


Randy said:
In particular...what is happening is...say two users are logged in. There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this. There
are several buttons on this page which go to different pages. One goes to
a screen which uses the Session["paypool"] object in a query (to Oracle)
to populate this new page. If both users click this button very close to
the same time, the second user will get the Session["paypool"] object of
the other user.


Christoph Wienands said:
Hey Randy,



What's the environment? OS, IIS, etc...
 
R

Randy

My app is in C#. I'm not very familiar with VB...the VB Module you're saying
is shared across threads? I didn't know that. But in my C# app, I'm not
sharing it that I'm aware of.
Thanks


Bruce Barker said:
this is almost always a bug in the asp.net code. most likely you are
storing a reference to a session variable in vb module (shared). this is a
no, no, as vb module variables are shared across threads.

-- bruce (sqlwork.com)


Randy said:
In particular...what is happening is...say two users are logged in. There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this. There
are several buttons on this page which go to different pages. One goes to
a screen which uses the Session["paypool"] object in a query (to Oracle)
to populate this new page. If both users click this button very close to
the same time, the second user will get the Session["paypool"] object of
the other user.


Christoph Wienands said:
Hey Randy,

Hello,
I'm having a strange problem. I've got a .NET web app which uses
Session variables. Sometime, not all the time, they get cross
threaded...that is...one user will have another user's Session
variable(s) data assigned to them. I can't figure out why. I've read
that other people are having this problem too but I haven't found a
resolution yet. Can someone please tell me how I might go about fixing
this?

What's the environment? OS, IIS, etc...
 
P

Patrice

Do you have static variables ? They are shared by the whole application
(i.e. all sessions using *the* application).

--
Patrice

Randy said:
My app is in C#. I'm not very familiar with VB...the VB Module you're saying
is shared across threads? I didn't know that. But in my C# app, I'm not
sharing it that I'm aware of.
Thanks


Bruce Barker said:
this is almost always a bug in the asp.net code. most likely you are
storing a reference to a session variable in vb module (shared). this is a
no, no, as vb module variables are shared across threads.

-- bruce (sqlwork.com)


Randy said:
In particular...what is happening is...say two users are logged in. There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this. There
are several buttons on this page which go to different pages. One goes to
a screen which uses the Session["paypool"] object in a query (to Oracle)
to populate this new page. If both users click this button very close to
the same time, the second user will get the Session["paypool"] object of
the other user.


message Hey Randy,

Hello,
I'm having a strange problem. I've got a .NET web app which uses
Session variables. Sometime, not all the time, they get cross
threaded...that is...one user will have another user's Session
variable(s) data assigned to them. I can't figure out why. I've read
that other people are having this problem too but I haven't found a
resolution yet. Can someone please tell me how I might go about fixing
this?

What's the environment? OS, IIS, etc...
 
R

Randy

Yes, I do have static variables. I'm not using any of them (that I know of)
to assign a value directly to a Session variable, but use of static
variables sounds like that might be what is causing it? Should I not use any
static variables?


Patrice said:
Do you have static variables ? They are shared by the whole application
(i.e. all sessions using *the* application).

--
Patrice

Randy said:
My app is in C#. I'm not very familiar with VB...the VB Module you're saying
is shared across threads? I didn't know that. But in my C# app, I'm not
sharing it that I'm aware of.
Thanks


Bruce Barker said:
this is almost always a bug in the asp.net code. most likely you are
storing a reference to a session variable in vb module (shared). this
is a
no, no, as vb module variables are shared across threads.

-- bruce (sqlwork.com)


In particular...what is happening is...say two users are logged in. There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this. There
are several buttons on this page which go to different pages. One goes to
a screen which uses the Session["paypool"] object in a query (to Oracle)
to populate this new page. If both users click this button very close to
the same time, the second user will get the Session["paypool"] object of
the other user.


message Hey Randy,

Hello,
I'm having a strange problem. I've got a .NET web app which uses
Session variables. Sometime, not all the time, they get cross
threaded...that is...one user will have another user's Session
variable(s) data assigned to them. I can't figure out why. I've read
that other people are having this problem too but I haven't found a
resolution yet. Can someone please tell me how I might go about fixing
this?

What's the environment? OS, IIS, etc...
 
P

Patrice

Do you affect a session value to such a variable ?

Those variables have an application wide scope. In the case of ASP.NET, it
means they are shared accross all sessions. So you 'll usually won't want
them in an ASP.NET application.

(using a shared property that return the value from the session variable
would work and could be a quick way to fix this problem).

--
Patrice

Randy said:
Yes, I do have static variables. I'm not using any of them (that I know of)
to assign a value directly to a Session variable, but use of static
variables sounds like that might be what is causing it? Should I not use any
static variables?


Patrice said:
Do you have static variables ? They are shared by the whole application
(i.e. all sessions using *the* application).

--
Patrice

Randy said:
My app is in C#. I'm not very familiar with VB...the VB Module you're saying
is shared across threads? I didn't know that. But in my C# app, I'm not
sharing it that I'm aware of.
Thanks


this is almost always a bug in the asp.net code. most likely you are
storing a reference to a session variable in vb module (shared). this
is a
no, no, as vb module variables are shared across threads.

-- bruce (sqlwork.com)


In particular...what is happening is...say two users are logged in. There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this. There
are several buttons on this page which go to different pages. One
goes
to
a screen which uses the Session["paypool"] object in a query (to Oracle)
to populate this new page. If both users click this button very
close
to
the same time, the second user will get the Session["paypool"]
object
of
the other user.


message Hey Randy,

Hello,
I'm having a strange problem. I've got a .NET web app which uses
Session variables. Sometime, not all the time, they get cross
threaded...that is...one user will have another user's Session
variable(s) data assigned to them. I can't figure out why. I've read
that other people are having this problem too but I haven't found a
resolution yet. Can someone please tell me how I might go about fixing
this?

What's the environment? OS, IIS, etc...
 
R

Randy

I was using a static in the screen (aspx file) where the anomaly was
occuring. I took out the static and slightly recoded and I believe it fixed
it! I can't seem to reproduce the anomaly. I'll keep testing, but I really
appreciate everyones help!
I'll never use static in an ASP app again :)
Thanks!

Patrice said:
Do you affect a session value to such a variable ?

Those variables have an application wide scope. In the case of ASP.NET, it
means they are shared accross all sessions. So you 'll usually won't want
them in an ASP.NET application.

(using a shared property that return the value from the session variable
would work and could be a quick way to fix this problem).

--
Patrice

Randy said:
Yes, I do have static variables. I'm not using any of them (that I know of)
to assign a value directly to a Session variable, but use of static
variables sounds like that might be what is causing it? Should I not use any
static variables?


Patrice said:
Do you have static variables ? They are shared by the whole application
(i.e. all sessions using *the* application).

--
Patrice

"Randy" <[email protected]> a écrit dans le message de
My app is in C#. I'm not very familiar with VB...the VB Module you're
saying
is shared across threads? I didn't know that. But in my C# app, I'm
not
sharing it that I'm aware of.
Thanks


this is almost always a bug in the asp.net code. most likely you are
storing a reference to a session variable in vb module (shared).
this
is
a
no, no, as vb module variables are shared across threads.

-- bruce (sqlwork.com)


In particular...what is happening is...say two users are logged in.
There
is a dropdown listbox which contains paypools. If the user changes
paypools, then the Session["paypool"] for that user is set to this.
There
are several buttons on this page which go to different pages. One goes
to
a screen which uses the Session["paypool"] object in a query (to
Oracle)
to populate this new page. If both users click this button very close
to
the same time, the second user will get the Session["paypool"] object
of
the other user.


message Hey Randy,

Hello,
I'm having a strange problem. I've got a .NET web app which uses
Session variables. Sometime, not all the time, they get cross
threaded...that is...one user will have another user's Session
variable(s) data assigned to them. I can't figure out why. I've read
that other people are having this problem too but I haven't found a
resolution yet. Can someone please tell me how I might go about
fixing
this?

What's the environment? OS, IIS, etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top