Multiple <Forms in 1.1

J

Jordan

I have a situation in which I need to:
1. Programmatically construct an html <form... method=POST> (NO
runat=server)
2. My user clicks to POST that form to a separate Web site.
3. When the <form gets posted to the other Web site, the other Web site
responds by showing a new page to my user - the new page is from the other
Web site. Essentially my user gets transferred to the other Web site at the
time the form gets posted.

I'd like to just construct the HTML for the <form> (to be POSTed to the
other site) as a string that gets injected into the aspx page on my site via
a Literal control. But the problem is that this would create a situation
where I have nested <forms (one is mine with runat=server, and the other is
the one I construct in code-behind and inject into the Literal). AFAIK,
nested forms is disallowed by the HTML specification.

So, how can I accomplish this objective? (I have to make this fly with 1.1).
I thought one workaround would be to just use the WebClient to POST the
<form to the other Web site, but I don't think that would allow the other
site to show my user the new page (from the other web site).

Any ideas?

Thanks!
 
J

Jordan

Clarification:
While my OP described the objective clearly, it could be even more clear : )
Steps 1 and 2 from the OP don't really need to happen (although they are one
way to satisfy the requirements).

Specifically, I don't need for the 2nd form to actually appear on my aspx
page and for the user to click to POST... if I can construct the <form> to
be POSTed to the other site in my code-behind (as a string), POST it to the
other site, AND have the user see the resulting page from the other site.
This would be ideal.

The part I don't understand is how to let the user see the page that the
other site sends in response to the POST sent via the WebClient in my
code-behind. If I can learn how to do this, then I'm good to go.

Sorry if this clarification of the problem causes any confusion...
 
S

S. Justin Gengo

Jordan,

One easy way would be to place the received stream into a literal control
like this:

'---Create the request

Dim WebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(New
Uri(CurrentLink))

WebRequest.Timeout = 2000

'---Get the response produced by the request

Dim Response As System.Net.WebResponse = WebRequest.GetResponse

'---Download the page content into a stream

Dim Stream As System.IO.Stream = Response.GetResponseStream

'---Place the stream into a stream reader

Dim StreamReader As New System.IO.StreamReader(Stream)

'---Read the stream into a string object

Dim HtmlReceived As String = StreamReader.ReadToEnd

'---Place the string into a literal control

Literal1.Text = HtmlReceived

'---Cleanup

Stream.Close()

StreamReader.Close()


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Jordan

Sounds good... one twist is that the other page is sending the user a
secured page (https) while mine is not secured (http).

Any other ideas?
 
S

S. Justin Gengo

Jordan,

In that case an iFrame is about your only choice...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top