Reputation: 45821
I am using ASP.Net + VSTS 2008 + .Net 3.5 + C# + IIS 7. I am wondering if at server side, I call response.redirect to another Url in the same web application, whether session will be continued or terminated?
e.g. if I set session variable foo to value "goo" in a.aspx, then in a.aspx I call response.redirect to b.aspx, whether in b.aspx I can 100% get the value for session variable foo to be "goo"? My confusion is I heard response.redirect will not 100% continue session, is that true?
thanks in advance, George
Upvotes: 3
Views: 10288
Reputation: 180
The Response.Redirect(url,false) function will change the session if the url was absolute url if you dont want to loose the session use absolute path instead .
Upvotes: 0
Reputation: 1
My problem was as follows :-
Problem: When we have moved the ASP.NET application to an another server (Windows Server 2008 R2) with IIS 7.5, the application cannot move session values between the pages. e.g. the session value was set in first page but it could not move to next page. In next page, value for same session variable was coming NULL.
Session values was moving to next page in case of Google Chrome and Firefox but not in Internet Explorer.
Resolution: We have created URL name with "_" (underscore)
Other Possible Solution:
Use Response.Redirect with having second parameter as "false" to avoid execution of page and thus to avoid lose session token. You have to use URL as follows. Response.Redirect("NextPage.aspx",false)
If the application pool of the site is configured as a web farm or a web garden (by setting the maximum number of worker processes to more than one), and if you're not using the session service or SQL sessions, incoming requests will unpredictably go to one of the worker processes, and if it's not the one the session was created on, it's lost. The solutions to this problem is either not to use a web garden if you don't need the performance boost, or use one of the out of process session providers.
Upvotes: 0
Reputation: 69372
Response.Redirect will kill your session and so it won't necessarily be available in b.aspx
. Instead, try using Response.Redirect("/b.aspx", false);
where the false parameter makes sure that the response is not immediately killed.
Upvotes: 2
Reputation: 38543
Session values are persisted through the life of the session. The session will end after the browser closes or the timeout expires, or explicitly closed.
http://msdn.microsoft.com/en-us/library/ms178581%28v=VS.90%29.aspx
Upvotes: 1