Is there a way to send info to another page without posting or using querystring?

A

Alan Silver

Hello,

I have a page where users can alter the contents of a shopping basket.
Once they are happy with the contents, they click a "checkout" button
and are taken to the checkout page.

What actually happens is that the "checkout" button causes a normal
postback, where some work is done before redirecting them to the
checkout page. I need to pass the basket ID to the checkout page, but
don't want to put it in the querystring as I don't want the user seeing
it. I can't (AFAIK) post to the checkout page as I'm doing this from the
code behind the basket page.

Any suggestions how I get the basket ID across without the user seeing
it? I thought about creating a session variable, then doing a
Response.Redirect and picking up the session variable in the checkout
page. That page would empty the session variable once it has been read.
This would probably work, but seems messy. Anyone got a neater solution?

TIA
 
G

Guest

pass it to a DB and reread it in on the next page...but again you would need
an unique ID to differentiate the user. The session (or cookie) storage of
the id is probably your best bet....
 
G

Guest

You could set a cookie. I personally like session and would choose that over
using a cookie, however.
 
S

S. Justin Gengo

Alan,

You could use Server.Transfer and pass the id to the new page in the context
object of the page.

Page1:

Context.Items.Add("BasketId", Value)
Server.Transfer("Page2.aspx")

Page2:

Dim BasketId As Int32 = Ctype(Context.Items.Item("BasketId"), Int32)

The only thing is that Server.Transfer bypasses the client so the client
will still have page1's web address in the address bar when the client shows
up on the checkout page. But that shouldn't matter...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
A

Alan Silver

Thanks to all of you for your replies. I just realised that using a
cookie or session variable is going to be a problem as I will be
redirecting to a page on another server (a secure one, unlike the main
site), so cookies and session variables will not be shared.

I have previously fiddled my way around this by including a dummy <img>
tag on the page, with the src of the image being set to a dynamic page
on the other server. That page sets a cookie and then returns some dummy
image. This is a trick to set a cookie on another server. I may try that
here.

As for the idea below, it looks clever, but I had a lot of problems
getting it to work neatly. I think I will try the above idea first and
see how that works.

Thanks again to all of you.
 
S

S. Justin Gengo

Alan,

I wasn't aware that the new page was on a different site/server.
Server.Transfer only works within a single application.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
A

Alan Silver

I wasn't aware that the new page was on a different site/server.
Server.Transfer only works within a single application.

Yup, my fault, I forgot to mention it. That's why I added the extra post
as it occurred to me that it would change things rather a lot.

I am currently thinking about having a page on the remote server that
takes the ID in the querystring, sets a cookie and immediately redirects
to another page on that server. The user would (hopefully) not see the
intermediate page, so the ID wouldn't be quite so obvious. I'm resigned
to the fact that it's very hard to hide it completely, but this may be
acceptable.

Thanks for the reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top