Forwarding the Request.Form collection

A

Agoston Bejo

Hi.

x1.asp:
<form method="post" action="x2.asp"> .... </form>

x2.asp:
DoSomeAdministration()
Response.Redirect "x3.asp?" & Request.Form

x3.asp: further processsing of data


This scenario works for a certain amount of data, but passing data in
Request.QueryString has its limits.
Is there any other way so that x3.asp can retrieve the data posted in
x1.asp? I could put the textual representation of Request.Form into a
session variable, but it would be much easier if I could pass on
Request.Form so that x3.asp would be able to access it the same way as it
could if x1.asp posted directly to x3.asp.
 
A

André Nobre

You can use hidden fields to do this, redirecting from x2 to x3 with java
script.
 
A

Agoston Bejo

The main point is not having to know what exactly is in Request.Form AND not
having to create forms for a simple redirect. (This latter could be
generated based on Request.Form but then I would need a javascript that
redirects a page etc. - too much work!)
 
J

Jeff Cochran

Hi.

x1.asp:
<form method="post" action="x2.asp"> .... </form>

x2.asp:
DoSomeAdministration()
Response.Redirect "x3.asp?" & Request.Form

x3.asp: further processsing of data


This scenario works for a certain amount of data, but passing data in
Request.QueryString has its limits.
Is there any other way so that x3.asp can retrieve the data posted in
x1.asp? I could put the textual representation of Request.Form into a
session variable, but it would be much easier if I could pass on
Request.Form so that x3.asp would be able to access it the same way as it
could if x1.asp posted directly to x3.asp.

Or do your processing in x2.asp without needing to move to x3.asp. Or
even post back to x1.asp, even displaying and repopulating the form if
need be.

Jeff
 
M

Michael D. Kersey

Agoston said:
Hi.

x1.asp:
<form method="post" action="x2.asp"> .... </form>

x2.asp:
DoSomeAdministration()
Response.Redirect "x3.asp?" & Request.Form

x3.asp: further processsing of data

This scenario works for a certain amount of data, but passing data in
Request.QueryString has its limits.
Is there any other way so that x3.asp can retrieve the data posted in
x1.asp? I could put the textual representation of Request.Form into a
session variable, but it would be much easier if I could pass on
Request.Form so that x3.asp would be able to access it the same way as it
could if x1.asp posted directly to x3.asp.

Server.Execute() may be what you want.
 
J

Johan Ramestam

Well, you could solve this in a pretty generic way, by iterating over
the Request.Form collection, generating a form with corresponding
hidden variables. And in the end, you include a Javascript that simply
submits the form (rather than doing a redirect).

Consider this simple function:

ForwardForm "x3.asp"

Sub ForwardForm(pstrURL)
Dim strKey
Response.Write("<form method=""post"" action=""" & pstrURL & """
name=""forwardForm"">")
For Each strKey In Request.Form
Response.Write("<input type=""hidden"" name=""" & strKey & """
value=""" & Request.Form(strKey) & """>")
Next
Response.Write("</form>")
Response.Write("<script language=""javascript"">")
Response.Write("if (document.forwardForm)
document.forwardForm.submit();")
Response.Write("</script>")
End Sub

Please note that you might need to escape certain characters (").

Regards,
Johan
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top