Forum Moderators: open

Message Too Old, No Replies

Response.redirect, but with http post

         

mikeyb

12:01 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



I want to redirect one ASP page to another, passing some data along with it, but I need the data to be hidden as if it was a http post from a form.

I have:
respose.redirect("page2.asp?id=1&name=mike")

But I don't want the variables & data to appear in the url in the browser.

Is this possible?

Cheers
Mike

lindajames

1:14 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



as far as i can understand it cannot be done server side. you will have to use client side javascript. what you could do is create a blank html file with the form field as follows:

<form name="login" action="file.asp" method="post">
<input type="hidden" name="id" value="1">
<input type="hidden" name="name" value="mike">
</form>

basically you store all the parameters in hidden fields and the use a javascript to submit the document. like this:

<body onload="document.login.submit();">

NOTE: where it says document.login "login" is the name of the form

hope that helps

Condor12

1:22 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



Why not try setting the values as Session variables?

In the first page do this;
Session("id")=id
Session("name")=name

Then redirect to the next page and on that page get the variables from the session info
id=Session("id")
name=Session("name")

:)

Alan

txbakers

1:54 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or you can use a transient page inbetween your two regular pages.

The transient page doesn't display anything, reads the URL with the QueryString, processes it quickly and then redirects back to a new page without the QueryString.

lindajames

2:01 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



thinking of it, i think using session to remember to value is a good idea or maybe even cookies and then get the cookie to expire immeditately

txbakers

2:04 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sessions are good too, but you have to be careful with them because:
a) they can eat up your memory pretty quickly
b) they linger in memory if not explicity destroyed or initialized with Session.Abandon

They can give you wrong results if not used carefully.

mikeyb

9:37 am on Jan 22, 2004 (gmt 0)

10+ Year Member



Thanks for your tips, I'll try the session idea.

Many thanks
Mike

RossWal

10:55 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



Server.transfer might help you out too. IIRC, it won't show the new url, hence it won't show the querystring. It appears to the user he is on the same page you transferreed away from.

Ross