Showing posts with label scenario. Show all posts
Showing posts with label scenario. Show all posts

Monday, March 26, 2012

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable'Can you write out the value of your session id to make sure it is not
changing between postbacks?
"Vlady" wrote:

> The scenario is the following: from the login page I set a session variabl
e
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, i
f
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill no
w!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type
,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable'

Session variable got lost after I switched to another server

The scenario is the following: from the login page I set a session variable
like
Session["USERID"]=3;
Server.transfer("anotherpage.aspx");
In anotherpage.aspx in page load I check to see if that Session is null, if
it's not show a javascript message window with the ID. The funny thing is
that the window is open, ->the variable gets to this page. Good, untill now!
If I click a button from this anotherpage.aspx to
Server.transfer(clients.aspx) and in clients.aspx I try to acces the
Session["USERID"] it says that it is gone (I mean if I cast to string type,
the resulting value is null).
Now the boom (for me) At work (Win 2000) this used to work, however when I
transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
What happens to that variable??Can you write out the value of your session id to make sure it is not
changing between postbacks?

"Vlady" wrote:

> The scenario is the following: from the login page I set a session variable
> like
> Session["USERID"]=3;
> Server.transfer("anotherpage.aspx");
> In anotherpage.aspx in page load I check to see if that Session is null, if
> it's not show a javascript message window with the ID. The funny thing is
> that the window is open, ->the variable gets to this page. Good, untill now!
> If I click a button from this anotherpage.aspx to
> Server.transfer(clients.aspx) and in clients.aspx I try to acces the
> Session["USERID"] it says that it is gone (I mean if I cast to string type,
> the resulting value is null).
> Now the boom (for me) At work (Win 2000) this used to work, however when I
> transfered at my house (WinXP Pro SP 1 with all updates) it doesn't!!!!
> What happens to that variable??

Session variable lost between pages

Here is a very interesting scenario.

I have a simple test application that loads a page and sets a session
variable on the load event. On the first page there is a link to a second
page. The load event of the second page displays the value of the session
variable.

The problem is that when I use a W2k machine, this little test works
perfect. Session variable value is displayed on the second page. However,
when I use my XPPro machine, the session variable is lost and nothing is
displayed.

Same version of IE. Same ASP.NET server. Just a different browser. I have
already played around with the privacy settings with no success. I am not
suspect of the server at this point, because the w2k computer works fine.

Any thoughts would be appreciated.

Thanks,
Marc.Are you sure that the session state setting is enabled within IIS? Although
ASP.Net may be setup the same, and the application settings may be the same,
the IIS settings themselves are a little different between IIS 5.0 and 5.1.
Session state usually starts with the web server itself and then it goes
down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
settings second.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> Here is a very interesting scenario.
> I have a simple test application that loads a page and sets a session
> variable on the load event. On the first page there is a link to a second
> page. The load event of the second page displays the value of the session
> variable.
> The problem is that when I use a W2k machine, this little test works
> perfect. Session variable value is displayed on the second page.
However,
> when I use my XPPro machine, the session variable is lost and nothing is
> displayed.
> Same version of IE. Same ASP.NET server. Just a different browser. I
have
> already played around with the privacy settings with no success. I am not
> suspect of the server at this point, because the w2k computer works fine.
> Any thoughts would be appreciated.
> Thanks,
> Marc.
Thanks Mark.

There is only one server that I am hitting from two different browsers,
therefore I believe the problems lies within the browser since the server is
the same.

Session state is enabled on the server.

Marc.

"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> Are you sure that the session state setting is enabled within IIS?
Although
> ASP.Net may be setup the same, and the application settings may be the
same,
> the IIS settings themselves are a little different between IIS 5.0 and
5.1.
> Session state usually starts with the web server itself and then it goes
> down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> settings second.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > Here is a very interesting scenario.
> > I have a simple test application that loads a page and sets a session
> > variable on the load event. On the first page there is a link to a
second
> > page. The load event of the second page displays the value of the
session
> > variable.
> > The problem is that when I use a W2k machine, this little test works
> > perfect. Session variable value is displayed on the second page.
> However,
> > when I use my XPPro machine, the session variable is lost and nothing is
> > displayed.
> > Same version of IE. Same ASP.NET server. Just a different browser. I
> have
> > already played around with the privacy settings with no success. I am
not
> > suspect of the server at this point, because the w2k computer works
fine.
> > Any thoughts would be appreciated.
> > Thanks,
> > Marc.
I am away from my computer with VS .Net, so I can't check, but as I recall
there are different methods for persisting the session variables. I think
one of them uses cookies. Is it possible that is the method being used for
your site and that the computer losing the session variables does not accept
cookies.

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> Thanks Mark.
> There is only one server that I am hitting from two different browsers,
> therefore I believe the problems lies within the browser since the server
is
> the same.
> Session state is enabled on the server.
> Marc.
>
> "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > Are you sure that the session state setting is enabled within IIS?
> Although
> > ASP.Net may be setup the same, and the application settings may be the
> same,
> > the IIS settings themselves are a little different between IIS 5.0 and
> 5.1.
> > Session state usually starts with the web server itself and then it goes
> > down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> > settings second.
> > Hope this helps,
> > Mark Fitzpatrick
> > Microsoft MVP - FrontPage
> > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > Here is a very interesting scenario.
> > > > I have a simple test application that loads a page and sets a session
> > > variable on the load event. On the first page there is a link to a
> second
> > > page. The load event of the second page displays the value of the
> session
> > > variable.
> > > > The problem is that when I use a W2k machine, this little test works
> > > perfect. Session variable value is displayed on the second page.
> > However,
> > > when I use my XPPro machine, the session variable is lost and nothing
is
> > > displayed.
> > > > Same version of IE. Same ASP.NET server. Just a different browser.
I
> > have
> > > already played around with the privacy settings with no success. I am
> not
> > > suspect of the server at this point, because the w2k computer works
> fine.
> > > > Any thoughts would be appreciated.
> > > > Thanks,
> > > Marc.
> >
Have completed disabled the privacy settings on the computer losing the
session variable. My thinking was the same that it must be related to
cookies, but this has not helped.

Marc.

"William F. LaMartin" <lamartin@.ix.netcom.com> wrote in message
news:%23OUS6h1oDHA.372@.TK2MSFTNGP11.phx.gbl...
> I am away from my computer with VS .Net, so I can't check, but as I recall
> there are different methods for persisting the session variables. I think
> one of them uses cookies. Is it possible that is the method being used
for
> your site and that the computer losing the session variables does not
accept
> cookies.
>
> "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> > Thanks Mark.
> > There is only one server that I am hitting from two different browsers,
> > therefore I believe the problems lies within the browser since the
server
> is
> > the same.
> > Session state is enabled on the server.
> > Marc.
> > "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> > news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > > Are you sure that the session state setting is enabled within IIS?
> > Although
> > > ASP.Net may be setup the same, and the application settings may be the
> > same,
> > > the IIS settings themselves are a little different between IIS 5.0 and
> > 5.1.
> > > Session state usually starts with the web server itself and then it
goes
> > > down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> > > settings second.
> > > > Hope this helps,
> > > Mark Fitzpatrick
> > > Microsoft MVP - FrontPage
> > > > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > > Here is a very interesting scenario.
> > > > > > I have a simple test application that loads a page and sets a
session
> > > > variable on the load event. On the first page there is a link to a
> > second
> > > > page. The load event of the second page displays the value of the
> > session
> > > > variable.
> > > > > > The problem is that when I use a W2k machine, this little test works
> > > > perfect. Session variable value is displayed on the second page.
> > > However,
> > > > when I use my XPPro machine, the session variable is lost and
nothing
> is
> > > > displayed.
> > > > > > Same version of IE. Same ASP.NET server. Just a different browser.
> I
> > > have
> > > > already played around with the privacy settings with no success. I
am
> > not
> > > > suspect of the server at this point, because the w2k computer works
> > fine.
> > > > > > Any thoughts would be appreciated.
> > > > > > Thanks,
> > > > Marc.
> > > > > >
I have found the answer and am posting it here to help anyone else avoid my
pain! So simple is the answer. ZoneAlarm Pro.

It seems that using any of the privacy settings in ZoneAlarmPro cause some
very unusual problems with asp.net. Zonealarm was consuming the cookies
causing the session to be reset on each postback. I have disabled the
privacy settings and everything is back to normal. In doing some research
on the web, I have read the Norton and Blackice do not create this problem.
This is something I will be doing more research into to confirm it for
myself.

My advice to all is when experiencing any problem with asp.net the first
thing you should do is disable virus and firewall software. Hopefully this
is advice I will remember next time myself. It is very easy to have a
problem consume you to the point where you forget the simple basic things.

Marc.

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:OqX7C44oDHA.1496@.TK2MSFTNGP11.phx.gbl...
> Have completed disabled the privacy settings on the computer losing the
> session variable. My thinking was the same that it must be related to
> cookies, but this has not helped.
> Marc.
>
> "William F. LaMartin" <lamartin@.ix.netcom.com> wrote in message
> news:%23OUS6h1oDHA.372@.TK2MSFTNGP11.phx.gbl...
> > I am away from my computer with VS .Net, so I can't check, but as I
recall
> > there are different methods for persisting the session variables. I
think
> > one of them uses cookies. Is it possible that is the method being used
> for
> > your site and that the computer losing the session variables does not
> accept
> > cookies.
> > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> > > Thanks Mark.
> > > > There is only one server that I am hitting from two different
browsers,
> > > therefore I believe the problems lies within the browser since the
> server
> > is
> > > the same.
> > > > Session state is enabled on the server.
> > > > Marc.
> > > > > > "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> > > news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > > > Are you sure that the session state setting is enabled within IIS?
> > > Although
> > > > ASP.Net may be setup the same, and the application settings may be
the
> > > same,
> > > > the IIS settings themselves are a little different between IIS 5.0
and
> > > 5.1.
> > > > Session state usually starts with the web server itself and then it
> goes
> > > > down to ASP/ASP.Net so I would suspect IIS first, then the
ASP/ASP.Net
> > > > settings second.
> > > > > > Hope this helps,
> > > > Mark Fitzpatrick
> > > > Microsoft MVP - FrontPage
> > > > > > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > > > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > > > Here is a very interesting scenario.
> > > > > > > > I have a simple test application that loads a page and sets a
> session
> > > > > variable on the load event. On the first page there is a link to
a
> > > second
> > > > > page. The load event of the second page displays the value of the
> > > session
> > > > > variable.
> > > > > > > > The problem is that when I use a W2k machine, this little test
works
> > > > > perfect. Session variable value is displayed on the second page.
> > > > However,
> > > > > when I use my XPPro machine, the session variable is lost and
> nothing
> > is
> > > > > displayed.
> > > > > > > > Same version of IE. Same ASP.NET server. Just a different
browser.
> > I
> > > > have
> > > > > already played around with the privacy settings with no success.
I
> am
> > > not
> > > > > suspect of the server at this point, because the w2k computer
works
> > > fine.
> > > > > > > > Any thoughts would be appreciated.
> > > > > > > > Thanks,
> > > > > Marc.
> > > > > > > > > > > >

Saturday, March 24, 2012

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!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

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!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.