Thursday, March 29, 2012
Session variable are shared between users
I keep several variables in a statevalue like:
Dim session As SessionState.HttpSessionState =
System.Web.HttpContext.Current.Session
session("connect") = " FKHFSF "
I thought that these variables would be the exclusive use of one connected
user/connection. But it looks like that in a multiuser enviroment some
variables are shared. So I end on the page somenone else was editing.
What am I missing here. (I have not modified any property of the session
variable)
TonNo other code than that ? It looks like it should work (of course all users
will have the same connect value if you store always FKHFSF for all users).
What if you are using directly System.Web.HttpContext.Current.Session.
Other than that , it would like as if you were using a shared property
somewhere...
Patrice
"ton" <vrs@.REMOVEhome.nl> a crit dans le message de
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
Session variable are shared between users
I keep several variables in a statevalue like:
Dim session As SessionState.HttpSessionState =
System.Web.HttpContext.Current.Session
session("connect") = " FKHFSF "
I thought that these variables would be the exclusive use of one connected
user/connection. But it looks like that in a multiuser enviroment some
variables are shared. So I end on the page somenone else was editing.
What am I missing here. (I have not modified any property of the session
variable)
TonNo other code than that ? It looks like it should work (of course all users
will have the same connect value if you store always FKHFSF for all users).
What if you are using directly System.Web.HttpContext.Current.Session.
Other than that , it would like as if you were using a shared property
somewhere...
Patrice
"ton" <vrs@.REMOVEhome.nl> a crit dans le message de
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
Ho do you test the multi-user environment?
Do you just open up the second browser?
If you opening it by using new window then you get the same session.
It's by design (of Browser).
Try to do the real test. From 2 different machines for example.
I can assure you that it works (unless your system is messed up big time)
George.
"ton" <vrs@.REMOVEhome.nl> wrote in message
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
it does not work on a second system.
But I've solved it allready. It looks that using sessionstate variables in a
customserver control is not reliable.
I've changed it to viewstate and now it works. Allthough I have to save de
logon values in a sessionstate, then when opening the second page (with
another customservercontrol) I read the sessionstate variable and save them
in viewstate. With these variabele I keep on using without any problem when
other users are opening the same page.
ton
"George Ter-Saakov" <nospam@.hotmail.com> schreef in bericht
news:eiLqniwGEHA.3068@.TK2MSFTNGP11.phx.gbl...
> Ho do you test the multi-user environment?
> Do you just open up the second browser?
> If you opening it by using new window then you get the same session.
> It's by design (of Browser).
> Try to do the real test. From 2 different machines for example.
> I can assure you that it works (unless your system is messed up big time)
> George.
> "ton" <vrs@.REMOVEhome.nl> wrote in message
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
Session variable are shared between users
I keep several variables in a statevalue like:
Dim session As SessionState.HttpSessionState =
System.Web.HttpContext.Current.Session
session("connect") = " FKHFSF "
I thought that these variables would be the exclusive use of one connected
user/connection. But it looks like that in a multiuser enviroment some
variables are shared. So I end on the page somenone else was editing.
What am I missing here. (I have not modified any property of the session
variable)
TonNo other code than that ? It looks like it should work (of course all users
will have the same connect value if you store always FKHFSF for all users).
What if you are using directly System.Web.HttpContext.Current.Session.
Other than that , it would like as if you were using a shared property
somewhere...
Patrice
"ton" <vrs@.REMOVEhome.nl> a crit dans le message de
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
Ho do you test the multi-user environment?
Do you just open up the second browser?
If you opening it by using new window then you get the same session.
It's by design (of Browser).
Try to do the real test. From 2 different machines for example.
I can assure you that it works (unless your system is messed up big time)
George.
"ton" <vrs@.REMOVEhome.nl> wrote in message
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
it does not work on a second system.
But I've solved it allready. It looks that using sessionstate variables in a
customserver control is not reliable.
I've changed it to viewstate and now it works. Allthough I have to save de
logon values in a sessionstate, then when opening the second page (with
another customservercontrol) I read the sessionstate variable and save them
in viewstate. With these variabele I keep on using without any problem when
other users are opening the same page.
ton
"George Ter-Saakov" <nospam@.hotmail.com> schreef in bericht
news:eiLqniwGEHA.3068@.TK2MSFTNGP11.phx.gbl...
> Ho do you test the multi-user environment?
> Do you just open up the second browser?
> If you opening it by using new window then you get the same session.
> It's by design (of Browser).
> Try to do the real test. From 2 different machines for example.
> I can assure you that it works (unless your system is messed up big time)
> George.
> "ton" <vrs@.REMOVEhome.nl> wrote in message
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> > Hi,
> > I keep several variables in a statevalue like:
> > Dim session As SessionState.HttpSessionState =
> > System.Web.HttpContext.Current.Session
> > session("connect") = " FKHFSF "
> > I thought that these variables would be the exclusive use of one
connected
> > user/connection. But it looks like that in a multiuser enviroment some
> > variables are shared. So I end on the page somenone else was editing.
> > What am I missing here. (I have not modified any property of the session
> > variable)
> > Ton
Session variable are shared between users
I keep several variables in a statevalue like:
Dim session As SessionState.HttpSessionState =
System.Web.HttpContext.Current.Session
session("connect") = " FKHFSF "
I thought that these variables would be the exclusive use of one connected
user/connection. But it looks like that in a multiuser enviroment some
variables are shared. So I end on the page somenone else was editing.
What am I missing here. (I have not modified any property of the session
variable)
TonNo other code than that ? It looks like it should work (of course all users
will have the same connect value if you store always FKHFSF for all users).
What if you are using directly System.Web.HttpContext.Current.Session.
Other than that , it would like as if you were using a shared property
somewhere...
Patrice
"ton" <vrs@.REMOVEhome.nl> a crit dans le message de
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
>
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
connected
>
No other code than that ! I save the logged in user, the page where I, the
details, the recordID of the record they asked.
but when 2 users connect via internet with my page, the values get mixed up.
I have to say that I've developed a Customserver control and that is using
the state variable
Ton
"Patrice" <nobody@.nowhere.com> schreef in bericht
news:eZGEnYLGEHA.1720@.tk2msftngp13.phx.gbl...
> No other code than that ? It looks like it should work (of course all
users
> will have the same connect value if you store always FKHFSF for all
users).
> What if you are using directly System.Web.HttpContext.Current.Session.
> Other than that , it would like as if you were using a shared property
> somewhere...
> Patrice
>
> "ton" <vrs@.REMOVEhome.nl> a crit dans le message de
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
connected
>
Ho do you test the multi-user environment?
Do you just open up the second browser?
If you opening it by using new window then you get the same session.
It's by design (of Browser).
Try to do the real test. From 2 different machines for example.
I can assure you that it works (unless your system is messed up big time)
George.
"ton" <vrs@.REMOVEhome.nl> wrote in message
news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
> Hi,
> I keep several variables in a statevalue like:
> Dim session As SessionState.HttpSessionState =
> System.Web.HttpContext.Current.Session
> session("connect") = " FKHFSF "
> I thought that these variables would be the exclusive use of one connected
> user/connection. But it looks like that in a multiuser enviroment some
> variables are shared. So I end on the page somenone else was editing.
> What am I missing here. (I have not modified any property of the session
> variable)
> Ton
>
it does not work on a second system.
But I've solved it allready. It looks that using sessionstate variables in a
customserver control is not reliable.
I've changed it to viewstate and now it works. Allthough I have to save de
logon values in a sessionstate, then when opening the second page (with
another customservercontrol) I read the sessionstate variable and save them
in viewstate. With these variabele I keep on using without any problem when
other users are opening the same page.
ton
"George Ter-Saakov" <nospam@.hotmail.com> schreef in bericht
news:eiLqniwGEHA.3068@.TK2MSFTNGP11.phx.gbl...
> Ho do you test the multi-user environment?
> Do you just open up the second browser?
> If you opening it by using new window then you get the same session.
> It's by design (of Browser).
> Try to do the real test. From 2 different machines for example.
> I can assure you that it works (unless your system is messed up big time)
> George.
> "ton" <vrs@.REMOVEhome.nl> wrote in message
> news:c4jor3$68l$1@.news1.tilbu1.nb.home.nl...
connected
>
Monday, March 26, 2012
session variable lost across different folders
A session variable that I have created can only be shared by the pages within the same directory where the page containing the session variable is sitting. Once I redirect the page to another page outside the folder (a different folder), the session variable is lost (empty). I understood that a session variable is meant to be used across all files in an application. Am I missing something here? Or I didn't setup properly?
Please help.
ThanksIs is useable throughout and application. IE if you have an application directory called /myapp then all folders under that directory will accept the session variable. (I think). There are a number of ways to get around this. If you tell me were the 2 differnt folders are located,(relative to eachother). and what kind of value you are trying to pass I'll be able to help you.
One last thing: what kinda of script are you trying to write? login page, shopping cart, etc...
Ryder
Thanks Ryder!
I have an application folder called 'QSAConnect' and under this folder there are several sub-folders. The page with the session variable called Session("StudentID") is saved in a sub-folder called 'AbsRecordEntry', and I want to redirect this page to another page, called absreport.aspx, which requires this Session("StudentID") as a passing parameter for all the functions. The target page(absreport.aspx) is located in a sub-directory called 'AbsReport'. Here is the code:
Sub btnViewReport_Click(sender As Object, e As EventArgs)
Dim strStudentID as string
strStudentID=lbxStudentLastName.Items(lbxStudentLastName.SelectedIndex).Value
Session("StudentID") = strStudentID
response.redirect(".../AbsReport/absreport.aspx")End Sub
This produced an empty session variable when the absreport.aspx loaded. But if I place the file absreport.aspx under AbsRecordEntry folder and change code to:
response.redirect("absreport.aspx")
there is no problem.
I hope you can understand my explanation.
Thanks again
Haiyi
hmmm, I created a similar situation on my testing server a few minutes ago and it worked fine. But what I did notice is that i wrote my response.redirect line a bit differntly and I think that may be it.
see, here is how you wrote yours: response.redirect(".../AbsReport/absreport.aspx")
and this is how I wrote mine: response.redirect("../AbsReport/absreport.aspx")
notice I only have 2 periods not 3. So my next step was to try my code with 3 periods. It generated an error, so i beleive that may be it. The only onther thing I could think of off the top of my head was that maybe the folder AbsRecordEntry or AbsReport is also an application directory. because this would cause a problem perhaps.
Let me know if this works.
Ryder