By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

Question about Session variables and Redirects

P: n/a
Hi All :-)

We have an APSX application using VB.net as the code behind, which uses one
or two session variables per page. These Session variables are passed to
the final page and calculations and summaries are done there. In order for
all of the values to appear on the last page, the user has to view each page
that has a session variable to be passed to the last page. The only way I
can think of to bypass the necessity of the user viewing each page is to do
a redirect if the value that is supposed to be passed is zero. This could
end up in every page needing to be viewed again. Does any one know of a way
to get the session values without redirecting the user to every page? Or,
is there a way to set the last page to run through a redirect for each page
without making them visible, and posting a JavaScript message saying that
the application is running the calculations and the process may take a few
moments? Any suggestions would be greatly appreciated.

TIA

Coleen
Nov 20 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
I must say I'm not really sure what you mean but you seem to pass variables
to pages and that's not session variable.

Session variables you don't need to pass along thru the pages, you just set
them and then read them.

Session("Page1_Variable1") = "Value"
Session("Page1_Variable2") = "Value"
etc...

Or...

You can set Variables in the Global.aspx page instead that you can access
all the time

Or did I misunderstand you?

/Lars Netzel
"Coleen" <co**********@yaho.com> skrev i meddelandet
news:eq*************@TK2MSFTNGP09.phx.gbl...
Hi All :-)

We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to
the final page and calculations and summaries are done there. In order for all of the values to appear on the last page, the user has to view each page that has a session variable to be passed to the last page. The only way I
can think of to bypass the necessity of the user viewing each page is to do a redirect if the value that is supposed to be passed is zero. This could
end up in every page needing to be viewed again. Does any one know of a way to get the session values without redirecting the user to every page? Or,
is there a way to set the last page to run through a redirect for each page without making them visible, and posting a JavaScript message saying that
the application is running the calculations and the process may take a few
moments? Any suggestions would be greatly appreciated.

TIA

Coleen

Nov 20 '05 #2

P: n/a
Hi Coleen,

In addition to Lars,

The session variables stays connected to the user (normaly using the cookie)
as long as the session is active.

That can be as long as that is set or as long as that there is no session
abort

All session variables you make on whatever page stay disposable for the
client during that time.

I hope this helps?

Cor
Nov 20 '05 #3

P: n/a
I guess it's difficult to explain without showing how the application works.
Okay, we start with a logon page, this sets a session variable for the
report period that is passed to every page viewed. From there, the user
selects "worksheets" where values from two summary pages are viewed. Those
values are retrieved from the database, but the values from the "worksheets"
need to be passed to the last page - the "Tax Return" (this is not an income
tax return) We pass the values to the tax return from the worksheets using
session variables. The problem is that if the user does not view all of the
worksheets first, the values do not get passed to the tax return. Is there a
way for me to redirect them from the tax return to a specific worksheet, if
the value is missing for that worksheet? I know I can do a
Response.Redirect(), but I may need to do multiple redirects, if they have
missed viewing multiple worksheets...I was just wondering if there is a way
to redirect them with out actually loading the page. Something that would
redirect, but not make the page visible, and post a pop-up message to let
them know the tax return is gathering the information (you know the type
that say "Getting information, this may take a few minutes..."

I hope this clarifies my problem. Any suggestions? TIA

Coleen
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I must say I'm not really sure what you mean but you seem to pass variables to pages and that's not session variable.

Session variables you don't need to pass along thru the pages, you just set them and then read them.

Session("Page1_Variable1") = "Value"
Session("Page1_Variable2") = "Value"
etc...

Or...

You can set Variables in the Global.aspx page instead that you can access
all the time

Or did I misunderstand you?

/Lars Netzel
"Coleen" <co**********@yaho.com> skrev i meddelandet
news:eq*************@TK2MSFTNGP09.phx.gbl...
Hi All :-)

We have an APSX application using VB.net as the code behind, which uses

one
or two session variables per page. These Session variables are passed to the final page and calculations and summaries are done there. In order

for
all of the values to appear on the last page, the user has to view each

page
that has a session variable to be passed to the last page. The only way I can think of to bypass the necessity of the user viewing each page is to

do
a redirect if the value that is supposed to be passed is zero. This could end up in every page needing to be viewed again. Does any one know of a

way
to get the session values without redirecting the user to every page? Or, is there a way to set the last page to run through a redirect for each

page
without making them visible, and posting a JavaScript message saying that the application is running the calculations and the process may take a few moments? Any suggestions would be greatly appreciated.

TIA

Coleen


Nov 20 '05 #4

P: n/a
That's why we wanted to use the session variable, since it is not kept like
a cookie is. I'm not quite sure what you mean by "All session variables you
make on whatever page stay disposable for the client during that time." ???
We want the session variable to be disposed at the end of their logon
session. The values are saved into the database after everything is
completed, so the session variables can be disposed of each time; but during
the session, we need the variables to do the calculations in the tax return
page (not income tax returns), so we need the variables passed from page to
page to page...to perform calculations. Thanks :-)

Coleen

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Coleen,

In addition to Lars,

The session variables stays connected to the user (normaly using the cookie) as long as the session is active.

That can be as long as that is set or as long as that there is no session
abort

All session variables you make on whatever page stay disposable for the
client during that time.

I hope this helps?

Cor

Nov 20 '05 #5

P: n/a
Hi Coleen,

My meaning of the word disposable, it shall use next time available.
Therefore I show again my text now with available and some extras.

The session stays available to the user (normally using the cookie) as long
as the session is active.

That can be as long as that is set or as long as that there is no session
abort

All session variables (items) you make, on whatever page, stay available for
the client during that time.

To make it more clear, the cookie works as a kind of key, which tells that
it is always the same user who connects to your server, and it has almost no
information.

All information you can store in the session items, they disappears when the
session aborts.

I hope this clears it something more?

Cor

Nov 20 '05 #6

P: n/a
Yes, it is clear, but it doesn't help (sorry) for my problem - which is how
to get the data from the pages that the users has not actually viewed. In
other words, I can get the session variable with no problem, as long as the
user views the page where the session variable is set...then it is passed
correctly to the tax return. But if the user views the tax return before
viewing the worksheet, the session variable is not set, and therefore is not
available to the tax return. I just want to know if there is a way to do a
redirect back to the page where the session variable is set, without making
the page visible. I need to get those values from each worksheet page to
the tax return. Is that more clear? How do I do a redirect back to the tax
return if I redirect to the worksheet that I need the value from? It's
basically a circle...I need to have each worksheet viewed or redirected to
from the tax return and then I need the tax return to redisplay with the
values from the worksheets. Any suggestion on how to do these redirects?
Thanks :-)
Coleen

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
Hi Coleen,

My meaning of the word disposable, it shall use next time available.
Therefore I show again my text now with available and some extras.

The session stays available to the user (normally using the cookie) as long as the session is active.

That can be as long as that is set or as long as that there is no session
abort

All session variables (items) you make, on whatever page, stay available for the client during that time.

To make it more clear, the cookie works as a kind of key, which tells that
it is always the same user who connects to your server, and it has almost no information.

All information you can store in the session items, they disappears when the session aborts.

I hope this clears it something more?

Cor

Nov 20 '05 #7

P: n/a
Hi Coleen,

What you asking sounds for me as the old Jewish joke/wisdom which I always
use for this kind of questions where the little Mosh asked to the Rabih
Can God make everything
And the Rabih says yes
And Mosh asks
Can God make a stone which he can himself not raise.
And the Rabih says nothing

However you can do.

If Session.item("MyItem") Is Nothing then
'The session item is not used yet
End if

I hope this helps?

Cor
Nov 20 '05 #8

P: n/a
Just set the Session variables when the user has entered the Value on that
page... on the last page where you need all the info, just check if the
variable has a value or not, or if it even exist (see Cor's Message)

This passing of variables is not nessessary when you work with SESSION
varaibles, they are always accessible... See my fist message in the thread!

You don't need cookies for this, if you dont' want... and besides, here in
sweden there were just a law created that you can't place cookies on users
clients without their permission or them beeing informed about it and what
the Coookies does!

/Lars Netzel
"Coleen" <co**********@yaho.com> skrev i meddelandet
news:eC**************@tk2msftngp13.phx.gbl...
Yes, it is clear, but it doesn't help (sorry) for my problem - which is how to get the data from the pages that the users has not actually viewed. In
other words, I can get the session variable with no problem, as long as the user views the page where the session variable is set...then it is passed
correctly to the tax return. But if the user views the tax return before
viewing the worksheet, the session variable is not set, and therefore is not available to the tax return. I just want to know if there is a way to do a redirect back to the page where the session variable is set, without making the page visible. I need to get those values from each worksheet page to
the tax return. Is that more clear? How do I do a redirect back to the tax return if I redirect to the worksheet that I need the value from? It's
basically a circle...I need to have each worksheet viewed or redirected to
from the tax return and then I need the tax return to redisplay with the
values from the worksheets. Any suggestion on how to do these redirects?
Thanks :-)
Coleen

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e0**************@tk2msftngp13.phx.gbl...
Hi Coleen,

My meaning of the word disposable, it shall use next time available.
Therefore I show again my text now with available and some extras.

The session stays available to the user (normally using the cookie) as long
as the session is active.

That can be as long as that is set or as long as that there is no session abort

All session variables (items) you make, on whatever page, stay available

for
the client during that time.

To make it more clear, the cookie works as a kind of key, which tells that it is always the same user who connects to your server, and it has

almost no
information.

All information you can store in the session items, they disappears when

the
session aborts.

I hope this clears it something more?

Cor


Nov 20 '05 #9

P: n/a
To answer your question and NOT telling you a better solution (which the
rest of the thread is discussing). You can't...

not... without a framesset anyway, if you have a framset you can do it but
it's the first time I have even heared of a solution based on a thing like
that!
For better solution use Cor's Solution with a Nothing check:

If Session.item("MyItem") Is Nothing then
'The session item is not used yet
End if

/Lars

"Coleen" <co**********@yaho.com> skrev i meddelandet
news:%2****************@tk2msftngp13.phx.gbl...
I guess it's difficult to explain without showing how the application works. Okay, we start with a logon page, this sets a session variable for the
report period that is passed to every page viewed. From there, the user
selects "worksheets" where values from two summary pages are viewed. Those values are retrieved from the database, but the values from the "worksheets" need to be passed to the last page - the "Tax Return" (this is not an income tax return) We pass the values to the tax return from the worksheets using
session variables. The problem is that if the user does not view all of the worksheets first, the values do not get passed to the tax return. Is there a way for me to redirect them from the tax return to a specific worksheet, if the value is missing for that worksheet? I know I can do a
Response.Redirect(), but I may need to do multiple redirects, if they have
missed viewing multiple worksheets...I was just wondering if there is a way to redirect them with out actually loading the page. Something that would
redirect, but not make the page visible, and post a pop-up message to let
them know the tax return is gathering the information (you know the type
that say "Getting information, this may take a few minutes..."

I hope this clarifies my problem. Any suggestions? TIA

Coleen
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I must say I'm not really sure what you mean but you seem to pass variables
to pages and that's not session variable.

Session variables you don't need to pass along thru the pages, you just

set
them and then read them.

Session("Page1_Variable1") = "Value"
Session("Page1_Variable2") = "Value"
etc...

Or...

You can set Variables in the Global.aspx page instead that you can access
all the time

Or did I misunderstand you?

/Lars Netzel
"Coleen" <co**********@yaho.com> skrev i meddelandet
news:eq*************@TK2MSFTNGP09.phx.gbl...
Hi All :-)

We have an APSX application using VB.net as the code behind, which
uses one
or two session variables per page. These Session variables are passed to the final page and calculations and summaries are done there. In
order for
all of the values to appear on the last page, the user has to view
each page
that has a session variable to be passed to the last page. The only
way I can think of to bypass the necessity of the user viewing each page is
to do
a redirect if the value that is supposed to be passed is zero. This could end up in every page needing to be viewed again. Does any one know of
a way
to get the session values without redirecting the user to every page?

Or, is there a way to set the last page to run through a redirect for each

page
without making them visible, and posting a JavaScript message saying that the application is running the calculations and the process may take a few moments? Any suggestions would be greatly appreciated.

TIA

Coleen



Nov 20 '05 #10

P: n/a
"Coleen" <co**********@yaho.com> wrote in message news:<eq*************@TK2MSFTNGP09.phx.gbl>...
Hi All :-)

We have an APSX application using VB.net as the code behind, which uses one
or two session variables per page. These Session variables are passed to


Coleen.

From your description, it appears that you are not collecting data
from the user on these pages. If that is the case, why not just check
to see which calculations have been missed and call the methods that
perform those in the final page.

HTH,

Charlie
Nov 20 '05 #11

P: n/a
> >
We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed
to
Coleen.

From your description, it appears that you are not collecting data
from the user on these pages. If that is the case, why not just check
to see which calculations have been missed and call the methods that
perform those in the final page.

Hi Charlie,

Intresting can you show me an example how to do that?
I assume you are not talking about session items with the missing
calculations or identificated cache objects.

Cor
Nov 20 '05 #12

P: n/a
"Cor Ligthert" <no**********@planet.nl> wrote in message news:<eO**************@tk2msftngp13.phx.gbl>...
Intresting can you show me an example how to do that?


Cor,

If my impression is right about user input requirements not needed
after first form then all the data and logic are already available at
the server and only need to be called in the proper order. Displaying
the pages shouldn't even be necessary.

Of course, if my assumption about user input is wrong, then you
already presented the most direct answer.

If user input is needed, then use logic based upon:

If Session.item("MyItem") Is Nothing then
'Go to appropiate page
End if

to decide which page to go to next.

A string of these if-then statements controlling the exit logic for
each page will create the structure to accomplish the initial goal.

Same could be used in entry of final form (tax return) to decide where
to redirect to and if only one form is incomplete then it would
automagically return to tax return form.

Charlie
Nov 20 '05 #13

P: n/a
Hi Charlie,

I placed the question to you because often people think that the information
is kept in the class in the same way as with window forms. That is not a
page is stateless, which means that when the page is sended again to the
client, the class goes completly out of scope. Information can only be
stored in:
.. a viewstate wich belongs to the page (sended with the page and returned
with that) however useless for this problem
.. a shared class which belongs to the application, which means available
to all users who visit the application (this information stays until the IIS
server goes down)
.. the cache what is almost the same as a shared class without methods and
events.
.. the session items which ends when the session ends.

I am not sure if I give indirect an answer to your message with this or that
you already knew this, but than this information is maybe usefull for
Coleen.

Cor.
Nov 20 '05 #14

P: n/a
"Cor Ligthert" <no**********@planet.nl> wrote in message news:<ut**************@TK2MSFTNGP11.phx.gbl>...
Hi Charlie,

I placed the question to you because often people think that the information
is kept in the class in the same way as with window forms. That is not a
page is stateless, which means that when the page is sended again to the


Cor,

Guilty! I have been working so much with winforms lately that I
wasn't thinking clearly about the charistics of asp.net.

I apologize for any confusion I may have caused. I claim old age as
my excuse ;)

Regards,
Charlie
Nov 20 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.