Tuesday, March 13, 2012

Session Variables getting cross threaded

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?

ThanksHey Randy,

"Randy" <temp@.temp.com> wrote in message
news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
> 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...
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

"Christoph Wienands" <christoph.wienands@.siemens.remove.com> wrote in
message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
> Hey Randy,
> "Randy" <temp@.temp.com> wrote in message
> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>> 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...
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" <christoph.wienands@.siemens.remove.com> wrote in
message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
> Hey Randy,
> "Randy" <temp@.temp.com> wrote in message
> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>> 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...
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" <temp@.temp.com> wrote in message
news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
> 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" <christoph.wienands@.siemens.remove.com> wrote in
> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
>> Hey Randy,
>>
>> "Randy" <temp@.temp.com> wrote in message
>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>>> 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...
>>
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" <brubar_nospamplease_@.safeco.com> wrote in message
news:%23U9VDgcyFHA.3408@.TK2MSFTNGP09.phx.gbl...
> 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" <temp@.temp.com> wrote in message
> news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
>> 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" <christoph.wienands@.siemens.remove.com> wrote in
>> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
>>> Hey Randy,
>>>
>>> "Randy" <temp@.temp.com> wrote in message
>>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>>>> 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...
>>>
>>
>>
Do you have static variables ? They are shared by the whole application
(i.e. all sessions using *the* application).

--
Patrice

"Randy" <temp@.temp.com> a crit dans le message de
news:OzXN1rcyFHA.3000@.TK2MSFTNGP12.phx.gbl...
> 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" <brubar_nospamplease_@.safeco.com> wrote in message
> news:%23U9VDgcyFHA.3408@.TK2MSFTNGP09.phx.gbl...
> > 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" <temp@.temp.com> wrote in message
> > news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
> >> 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" <christoph.wienands@.siemens.remove.com> wrote in
> >> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
> >>> Hey Randy,
> >>>
> >>> "Randy" <temp@.temp.com> wrote in message
> >>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
> >>>> 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...
> >>>
> >>
> >>
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" <nobody@.nowhere.com> wrote in message
news:OYhp6%23cyFHA.3856@.tk2msftngp13.phx.gbl...
> Do you have static variables ? They are shared by the whole application
> (i.e. all sessions using *the* application).
> --
> Patrice
> "Randy" <temp@.temp.com> a crit dans le message de
> news:OzXN1rcyFHA.3000@.TK2MSFTNGP12.phx.gbl...
>> 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" <brubar_nospamplease_@.safeco.com> wrote in message
>> news:%23U9VDgcyFHA.3408@.TK2MSFTNGP09.phx.gbl...
>> > 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" <temp@.temp.com> wrote in message
>> > news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
>> >> 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" <christoph.wienands@.siemens.remove.com> wrote in
>> >> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
>> >>> Hey Randy,
>> >>>
>> >>> "Randy" <temp@.temp.com> wrote in message
>> >>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>> >>>> 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...
>> >>>
>> >>
>> >>
>>>>
>>
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" <temp@.temp.com> a crit dans le message de
news:OrwZuIdyFHA.1168@.TK2MSFTNGP10.phx.gbl...
> 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" <nobody@.nowhere.com> wrote in message
> news:OYhp6%23cyFHA.3856@.tk2msftngp13.phx.gbl...
> > Do you have static variables ? They are shared by the whole application
> > (i.e. all sessions using *the* application).
> > --
> > Patrice
> > "Randy" <temp@.temp.com> a crit dans le message de
> > news:OzXN1rcyFHA.3000@.TK2MSFTNGP12.phx.gbl...
> >> 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" <brubar_nospamplease_@.safeco.com> wrote in message
> >> news:%23U9VDgcyFHA.3408@.TK2MSFTNGP09.phx.gbl...
> >> > 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" <temp@.temp.com> wrote in message
> >> > news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
> >> >> 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" <christoph.wienands@.siemens.remove.com> wrote
in
> >> >> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
> >> >>> Hey Randy,
> >> >>>
> >> >>> "Randy" <temp@.temp.com> wrote in message
> >> >>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
> >> >>>> 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...
> >> >>>
> >> >>
> >> >>
> >> >> >>
> >>
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" <nobody@.nowhere.com> wrote in message
news:OJInWYdyFHA.2644@.TK2MSFTNGP09.phx.gbl...
> 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" <temp@.temp.com> a crit dans le message de
> news:OrwZuIdyFHA.1168@.TK2MSFTNGP10.phx.gbl...
>> 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" <nobody@.nowhere.com> wrote in message
>> news:OYhp6%23cyFHA.3856@.tk2msftngp13.phx.gbl...
>> > Do you have static variables ? They are shared by the whole application
>> > (i.e. all sessions using *the* application).
>>> > --
>> > Patrice
>>> > "Randy" <temp@.temp.com> a crit dans le message de
>> > news:OzXN1rcyFHA.3000@.TK2MSFTNGP12.phx.gbl...
>> >> 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" <brubar_nospamplease_@.safeco.com> wrote in message
>> >> news:%23U9VDgcyFHA.3408@.TK2MSFTNGP09.phx.gbl...
>> >> > 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" <temp@.temp.com> wrote in message
>> >> > news:ewp90QcyFHA.3588@.tk2msftngp13.phx.gbl...
>> >> >> 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" <christoph.wienands@.siemens.remove.com> wrote
> in
>> >> >> message news:%235WsR4byFHA.3892@.TK2MSFTNGP12.phx.gbl...
>> >> >>> Hey Randy,
>> >> >>>
>> >> >>> "Randy" <temp@.temp.com> wrote in message
>> >> >>> news:O54H7QbyFHA.736@.tk2msftngp13.phx.gbl...
>> >> >>>> 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...
>> >> >>>
>> >> >>
>> >> >>
>> >>> >>> >>
>> >>
>>>>
>>

0 comments:

Post a Comment