WebClient

R

Rippo

Hi

I need to post a form to an external URL, get a repsonse, then repost
to an external URL and redirect at the same time. I can figure out step
1 and step 2 fine but I cant seem to figure out how to send a form and
send the client to the external url at the same time. Can anyone help?

'Step 1 create form data
Dim formPostData As String = String.Empty
formPostData &= "AmountPaid=" & Booking.AmountPaid
formPostData &= "Fullname=" & Booking.Fullname

'Step 2 send to XXXX and get response
client = New Net.WebClient
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
postByteArray = Encoding.ASCII.GetBytes(formPostData)
responseArray = client.UploadData(PaymentURL, "POST", postByteArray)
response = Encoding.ASCII.GetString(responseArray)

'step 3 recreate form and send on to exteranl url
formPostData = "epdqData=" & response
client = New Net.WebClient
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
postByteArray = Encoding.ASCII.GetBytes(formPostData)
client.UploadData(PaymentURL, "POST", postByteArray)

HOW DO I SEND CLIENT ON TO EXTERNAL URL HERE?

many thanks
Rippo
 
S

Steve C. Orr [MVP, MCSD]

To post the form to an external site while sending the user there as well,
you can simply output a standard webform with the fields all filled in.
Then output a line of Javascript such as document.submit().
This will send the page to the user's browser and immediately submit it as
if the user had themselves clicked the submit button on the form.
 

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,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top