WebClient

Discussion in 'ASP .Net' started by Rippo, Jun 14, 2006.

  1. Rippo

    Rippo Guest

    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
    Rippo, Jun 14, 2006
    #1
    1. Advertising

  2. 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.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Rippo" <> wrote in message
    news:...
    > 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
    >
    Steve C. Orr [MVP, MCSD], Jun 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yysiow

    WebClient Problem

    yysiow, Jul 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    442
    Sandeep Alur
    Jul 10, 2003
  2. belfast neil

    webclient.uploadfile application question

    belfast neil, Jul 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    441
    belfast neil
    Jul 28, 2003
  3. bruce barker

    Re: WebClient Uploading error

    bruce barker, Jul 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    354
    bruce barker
    Jul 30, 2003
  4. Martin Kuba

    CookieContainer with WebClient

    Martin Kuba, Aug 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    633
    Martin Kuba
    Aug 5, 2003
  5. YA
    Replies:
    1
    Views:
    567
    Chris Langsenkamp
    Aug 12, 2003
Loading...

Share This Page