472,341 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

Session Variables Object Lost On Redirect

Frinavale
9,735 Expert Mod 8TB
I currently have a website that collects information (mainly text and integers) inputed by users and stores that information into an object which is in turn stored in Session. Each page has its own object and each object knows if it is valid or not.

Everytime the user advances to the next page it checks to see if all of the data collected up to this point is valid by checking the objects which are stored in Session.

If the object is missing or if the data is invalid the user is redirected back to the page where the error was made.

Now here's the problem....when I redirect them back to the page they came from because the object contains invalid data, the object is no longer there.

I have no idea why this happens but I would like to redisplay the data on the screen (with error messages) when the user is redirected back but I cannot do this because somehow the objects no longer exist.

Has anyone got any thoughts on why this might be?
Oct 13 '06 #1
4 8113
Post some code, it sounds like your just not putting it into the session correctly. I have had some problems with this and found it easiest to pass my information to a page that its only purpose is to create the sessions.

Basically I don't load my sessions on the same page as my information.

Justin
Oct 18 '06 #2
Frinavale
9,735 Expert Mod 8TB
I'm starting to think that the reason I lose my session variables is because when the user types in the url of the page a new session is created and so my variables are lost. I don't know if I'm correct or not, but it does seem weird that on the page that they type the objects are there, and then when they are redirected (after putting all the objects into session) the objects are lost.

Here is some snipets of my code on the page that the user is redirected to.
************************************************** *****************************************

Expand|Select|Wrap|Line Numbers
  1. Private Sub GetAllObjectsFromSession()
  2.         'Getting all objects from session
  3.         page1Info= CType(Session("page1Info"), FirstPageInfo)
  4.         page2Info = CType(Session("page2Info"), SecondPageInfo)
  5.         page3Info = CType(Session("page3Info"), ThirdPageInfo)
  6. End Sub
  7.     Private Sub GetAllObjectsFromSession()
  8.         'Getting all objects from session
  9.         Session("page1Info") =page1Info
  10.         Session("page2Info") =page2Info 
  11.         Session("page3Info") =page3Info 
  12. End Sub
  13.  
  14.  
  15.  
  16.  
  17. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  18.  
  19.         GetAllObjectsFromSession()
  20.         If IsPostBack Then
  21.             'there is some code here but will be confusing so I'm not going to post it
  22.        Else
  23.        'clearing the errors, and filling in the information supplied earlier
  24.                        Try
  25.                             clearErrors()
  26.  
  27.                             'checking if the objects are valid and if not displaying approriate errors
  28.                             If Not page1Info.IsValid()Then
  29.                                 displayErrors()
  30.                             End If
  31.                         Catch ex2 As Exception
  32.                             page1Info= New FirstPageInfo
  33.                             PutAllObjectsIntoSession()
  34.                         End Try
  35.             End If
  36.  
Oct 23 '06 #3
scripto
143 100+
Couple of things

1. Session variables work only when you allow cookies, so make sure accept cookies is turned on.

2. If you use Response.Redirect() in .NET, you will have problems with Session vars. Instead use either
Response.Redirsct("nextpage.aspx", false) or
Server.Transfer()

hope this helps.
Oct 24 '06 #4
Frinavale
9,735 Expert Mod 8TB
Couple of things

1. Session variables work only when you allow cookies, so make sure accept cookies is turned on.

2. If you use Response.Redirect() in .NET, you will have problems with Session vars. Instead use either
Response.Redirsct("nextpage.aspx", false) or
Server.Transfer()

hope this helps.
I have tried Server.Transfer before but ran into an interesting issue and read about a few problems that happen when you have presistant data...

When I tried Server.Transfer the first page wrote to the Response buffer and then when we were directed (with server.transfer) to the second page that page's content was then appended to the first page's content. This would effectivly show 2 pages on one page.

I couldn't figure out how to flush the buffer just before the new content was written so I changed back to Response.Redirect.

I've never heard of Response.Redirsct("nextpage.aspx", false) so I will look it up and see if it helps. Thanks alot!
Oct 24 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alex | last post by:
Thank you in advance. My ASP page 1 redirect user to third party's website, after the process at third party is finished, in 3rd party's...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first...
14
by: Michael Carr | last post by:
I have an intermittent problem that occurs on a very small number of browsers that access my website. The strange thing is this: my site works...
3
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session...
3
by: catweezle2010 | last post by:
Hello NG, I have three files (default.aspx, search.aspx and work.aspx). The way is: login on default (if session is newsession). The loginname I...
7
by: Erik | last post by:
I have an application that uses sessions variables a lot but one I publish the application on the prod server these variables are lost. The...
0
by: Dornel | last post by:
Hi all, My session variables are lost when I using response.redirect at first time... In the second time, the problem not exists. example in...
2
by: Ned Balzer | last post by:
Hi, Apologies if this is a newbie question, I haven't found the answer in any faqs. I have an asp.net 2.0 page that sets session variables and...
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users...
14
by: Rick | last post by:
We are in the process of testing a large web project that I converted from VS 2003 to VS 2005. Everything seems to be working except for a few minor...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.