469,627 Members | 1,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,627 developers. It's quick & easy.

Session variable scope in a Load Balanced environment

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!

Dec 28 '05 #1
1 3353
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.

Dec 28 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by gfuller | last post: by
3 posts views Thread by Simon Niederberger | last post: by
7 posts views Thread by Nicole | last post: by
4 posts views Thread by Dean | last post: by
8 posts views Thread by Anthony P. Mancini | last post: by
5 posts views Thread by Pross | last post: by
4 posts views Thread by Abi | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.