Re: Session variables problem
From: Simon Matthews (SimonMatthews_at_discussions.microsoft.com)
Date: 12/02/04
- Next message: Asha: "question on global.ascx"
- Previous message: z. f.: "Re: validator stop working"
- In reply to: Joe Fallon: "Re: Session variables problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 2 Dec 2004 00:31:02 -0800
Joe,
I was doing this but storing the data in a 'known' session variable. The
problem I got was when a user completes two searches of the same type (ie.
same asp pages) but different criteria. As I was storing the criteria in the
same variable it caused problems if the user pressed the back button and
returned to an earlier page.
However with advice from Bruce & Scott I have stored the criteria structure
in the session but referenced with a key which is passed in the query string
rather than a set variable name.
So I have:-
http://www.mysite.com?Search=27611
I then have in the second page to read out the data.
:-
SearchData = (SearchDataStruct) Session["27611"];
This seems to work okay but i now have a concern over building up a lot of
redundant data over time in the session. As this is a intranet application
sessions could be quite long and large.
Simon.
"Joe Fallon" wrote:
> Simon,
> I use Session to store my search criteria classes all the time.
> Then on the results page I pull the criteria out of session, and use it to
> build the SQL command to get the results which are displayed in the grid.
>
> If the user retunrs to the Search page, I pull the crtieria class out of
> session and populate the search controls with the data they last entered.
> They can then change some settings or push the Clear Form button to re-set
> all the values to their defaults.
>
> This sounds exactly like what you are trying to do (except you use a
> Structure instead of a class which is not very different.)
>
> I guess I don't see what the problem is that you are having. This technique
> works well for me.
> Can you please elaborate a bit?
> --
> Joe Fallon
>
>
>
> "Simon Matthews" <SimonMatthews@discussions.microsoft.com> wrote in message
> news:A935A4AB-6BF9-436A-9C24-C68BF625F179@microsoft.com...
> >I am having issues with the right way to architecture the following (using
> >c#
> > asp.net):-
> >
> > The question I have is how best pass the collected data from one web page
> > for use in another.
> >
> > The question I have is how best pass the search criteria from the first
> > page
> > to the second. The search criteria exists as a structure and is filled
> > when
> > the user presses the 'Search' button on the first page.
> >
> > 1. Present an asp page for collecting user search criteria
> > 2. Show grid with results of search after querying SQL
> >
> >
> >
> > If I use the session to store it, then this causes problems as the session
> > variable is overwritten on a second search by the user, but a couple of
> > presses on the back button of the browser will get you to a page expecting
> > different criteria in the session from earlier which is no longer there.
> >
> > ViewState seems no good as it only works on postback and the above issue
> > would still cause a problem.
> >
> > I do not want to pass the search criteria in the address line as this is
> > messy and allows the user to change and view it.
> >
> > I beleive you can also use Server.Transfer but I think this would have a
> > similiar issue with the data being available long-term.
> >
> > Any pointers as to the correct approach to this would be most welcome.
>
>
>
- Next message: Asha: "question on global.ascx"
- Previous message: z. f.: "Re: validator stop working"
- In reply to: Joe Fallon: "Re: Session variables problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|