Saturday, March 24, 2012
Session variable scope in a Load Balanced environment
sticky sessions):
There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.
My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?
Any help will be appriciated.
Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:
> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to th
e
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.
Session variable scope in a Load Balanced environment
sticky sessions):
There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.
My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?
Any help will be appriciated.
Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:
> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to the
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.
Tuesday, March 13, 2012
Session variables and cookies are incorrectly accessible between applications
until it was tested in multisession environment. When 2 users access the
same aspx page at the same time sometimes the session variable of first
session is visible to second session instead of his own session
variable.
In Web.config file session mode is set to InProc and cookieless="false".
Nothing changed when I change cookieless="true". Then I replaced session
variables with cookies and it still didn't correct the problem. What can
be wrong? How session variables can be accessable to another session if
they are saved in cookies? How cookies are accessable to another
session?
Thanks
Galina
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!they aren't. its a coding error on your part. you are probably storing
session variables as shared or in vb module.
-- bruce (sqlwork.com)
"Galina Grechka" <galina@.datatracplus.com> wrote in message
news:uNbg7ha$EHA.3472@.TK2MSFTNGP14.phx.gbl...
| Hi, I have a really bad problem with ASP.net application. It seemed fine
| until it was tested in multisession environment. When 2 users access the
| same aspx page at the same time sometimes the session variable of first
| session is visible to second session instead of his own session
| variable.
| In Web.config file session mode is set to InProc and cookieless="false".
| Nothing changed when I change cookieless="true". Then I replaced session
| variables with cookies and it still didn't correct the problem. What can
| be wrong? How session variables can be accessable to another session if
| they are saved in cookies? How cookies are accessable to another
| session?
|
| Thanks
| Galina
|
|
|
| *** Sent via Developersdex http://www.examnotes.net ***
| Don't just participate in USENET...get rewarded for it!
I create session variables in aspx.vb file - code behind aspx page.
Where am I suposed to do this?
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
The problem was that by defauld aspx page can be cached on web server. I
specified Location="Client" in OutputCache directive and it fixed the
problem.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Session variables and cookies are incorrectly accessible between applications
until it was tested in multisession environment. When 2 users access the
same aspx page at the same time sometimes the session variable of first
session is visible to second session instead of his own session
variable.
In Web.config file session mode is set to InProc and cookieless="false".
Nothing changed when I change cookieless="true". Then I replaced session
variables with cookies and it still didn't correct the problem. What can
be wrong? How session variables can be accessable to another session if
they are saved in cookies? How cookies are accessable to another
session?
Thanks
Galina
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!they aren't. its a coding error on your part. you are probably storing
session variables as shared or in vb module.
-- bruce (sqlwork.com)
"Galina Grechka" <galina@.datatracplus.com> wrote in message
news:uNbg7ha$EHA.3472@.TK2MSFTNGP14.phx.gbl...
| Hi, I have a really bad problem with ASP.net application. It seemed fine
| until it was tested in multisession environment. When 2 users access the
| same aspx page at the same time sometimes the session variable of first
| session is visible to second session instead of his own session
| variable.
| In Web.config file session mode is set to InProc and cookieless="false".
| Nothing changed when I change cookieless="true". Then I replaced session
| variables with cookies and it still didn't correct the problem. What can
| be wrong? How session variables can be accessable to another session if
| they are saved in cookies? How cookies are accessable to another
| session?
|
| Thanks
| Galina
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
I create session variables in aspx.vb file - code behind aspx page.
Where am I suposed to do this?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
The problem was that by defauld aspx page can be cached on web server. I
specified Location="Client" in OutputCache directive and it fixed the
problem.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Session variables are mixing each other with multiple login....
When the user does multiple logins to the system and navigates to different
screens and clicks back button sometimes it reading the session variables
values are mixing each other.
How to avoid this kind of situation? Basically I am looking for the steps to
be taken when we develop web based application using ASP.Net (.Net framework
1.1) for multiple logins.
Shashii would think this would only happen if you are creating new windows in IE
from an existing one that is open. if so then they would share the same
session id. if you create a new instance of IE for each logon, then this is a
little strange.
what type of logon are you using, your own, or forms? or windows or passport?
"Shashi" wrote:
> My development environment is ASP.Net 1.1.
> When the user does multiple logins to the system and navigates to different
> screens and clicks back button sometimes it reading the session variables
> values are mixing each other.
> How to avoid this kind of situation? Basically I am looking for the steps to
> be taken when we develop web based application using ASP.Net (.Net framework
> 1.1) for multiple logins.
> Shashi
>
Thanks for your reply.
1. I am using my own login. Checking the user id and password in the
database.
2. Here is the sequence.
* Default.aspx is the default page for the website.
* Load event of this page, I am opening a new page(Login Page) using
the following java script.
Response.Write( "window.open('" & URL & "','" & "WindowName"
& Session.SessionID & "','" &
toolbar=no,location=no,titlebar=no,directories=no, status=yes,menubar=no,scro
llbars=yes,copyhistory=no,menubar=no,scrollbars=1, resizable=1,height=" &
Chr(34) & " + maxh+" & Chr(34) & ",width=" & Chr(34) & " + maxw+" & Chr(34)
& ",left=0,top=0" & "');" & vbCrLf))
* In Login page the user(U1) will login to the sytem.
*Enters Customer # and navigates to the customer page.
*Other user(U2) logs in the same way and navigates to the customer
screen.
* User2 through popup menu selects Back and navigates back.
* USer U1 through popup menu selects Back and navigates back
*Instead of displaying the U1 profile system is displaying the U2
profile. That means I have text box with user ID displayed from a session
variable which got wrong data.
Please advice.
Shashi
"chriscollinson" <chriscollinson@.discussions.microsoft.com> wrote in message
news:CCE62572-A6C0-4B20-BD91-F5E873D59CA8@.microsoft.com...
> i would think this would only happen if you are creating new windows in IE
> from an existing one that is open. if so then they would share the same
> session id. if you create a new instance of IE for each logon, then this
is a
> little strange.
> what type of logon are you using, your own, or forms? or windows or
passport?
> "Shashi" wrote:
> > My development environment is ASP.Net 1.1.
> > When the user does multiple logins to the system and navigates to
different
> > screens and clicks back button sometimes it reading the session
variables
> > values are mixing each other.
> > How to avoid this kind of situation? Basically I am looking for the
steps to
> > be taken when we develop web based application using ASP.Net (.Net
framework
> > 1.1) for multiple logins.
> > Shashi
Session variables are mixing each other with multiple login....
When the user does multiple logins to the system and navigates to different
screens and clicks back button sometimes it reading the session variables
values are mixing each other.
How to avoid this kind of situation? Basically I am looking for the steps to
be taken when we develop web based application using ASP.Net (.Net framework
1.1) for multiple logins.
Shashii would think this would only happen if you are creating new windows in IE
from an existing one that is open. if so then they would share the same
session id. if you create a new instance of IE for each logon, then this is
a
little strange.
what type of logon are you using, your own, or forms? or windows or passport
?
"Shashi" wrote:
> My development environment is ASP.Net 1.1.
> When the user does multiple logins to the system and navigates to differe
nt
> screens and clicks back button sometimes it reading the session variables
> values are mixing each other.
> How to avoid this kind of situation? Basically I am looking for the steps
to
> be taken when we develop web based application using ASP.Net (.Net framewo
rk
> 1.1) for multiple logins.
> Shashi
>
>
Thanks for your reply.
1. I am using my own login. Checking the user id and password in the
database.
2. Here is the sequence.
* Default.aspx is the default page for the website.
* Load event of this page, I am opening a new page(Login Page) using
the following java script.
Response.Write( "window.open('" & URL & "','" & "WindowName"
& Session.SessionID & "','" &
toolbar=no,location=no,titlebar=no,direc
tories=no,status=yes,menubar=no,scro
llbars=yes,copyhistory=no,menubar=no,scr
ollbars=1,resizable=1,height=" &
Chr(34) & " + maxh+" & Chr(34) & ",width=" & Chr(34) & " + maxw+" & Chr(34)
& ",left=0,top=0" & "');" & vbCrLf))
* In Login page the user(U1) will login to the sytem.
*Enters Customer # and navigates to the customer page.
*Other user(U2) logs in the same way and navigates to the customer
screen.
* User2 through popup menu selects Back and navigates back.
* USer U1 through popup menu selects Back and navigates back
*Instead of displaying the U1 profile system is displaying the U2
profile. That means I have text box with user ID displayed from a session
variable which got wrong data.
Please advice.
Shashi
"chriscollinson" <chriscollinson@.discussions.microsoft.com> wrote in message
news:CCE62572-A6C0-4B20-BD91-F5E873D59CA8@.microsoft.com...
> i would think this would only happen if you are creating new windows in IE
> from an existing one that is open. if so then they would share the same
> session id. if you create a new instance of IE for each logon, then this
is a
> little strange.
> what type of logon are you using, your own, or forms? or windows or
passport?
> "Shashi" wrote:
>
different
variables
steps to
framework