Creating POST data for Server.Transfer()?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Veeneman

    Creating POST data for Server.Transfer()?

    I want to programmaticall y create some POST data on a web server, then pass
    that data to another web page that the server calls, using
    Server.Transfer (). What's the best way to do that?

    I'm programming some buttons that link to PayPal's shopping cart. The
    shopping cart needs a bunch of data about the item being added, including
    price. PayPal's sample markup puts the data in a hidden form, which the
    button submits.

    I'm concerned about the lack of security in that approach, so I want to have
    the button invoke a method on the server that will assemble the POST data
    that PayPal needs, and then redirect to PayPal. Right now I have a 'button
    dispatch' page, which contains the data assembly and redirect
    (Server.Transfe r()) code in its Page_Load event.

    What I can't figure out is how to get the POST data into the Request the
    page will submit when it redirects to PayPal. What's the simplest way to do
    this? Are there any examples? Thanks much.

    David Veeneman
    Foresight Systems





  • David Veeneman

    #2
    Re: Creating POST data for Server.Transfer ()?

    My bad. Server.Transfer won't call an external page or make a request.

    I'm still stuck with my basic problem of needing to create POST data
    programmaticall y and sending it to PayPall, and ending up on the PayPal page
    I sent the data to. Any ideas?


    Comment

    • Carl Daniel [VC++ MVP]

      #3
      Re: Creating POST data for Server.Transfer ()?

      "David Veeneman" <dcv@nospam.com wrote in message
      news:O4H6hcqAHH A.5068@TK2MSFTN GP02.phx.gbl...
      My bad. Server.Transfer won't call an external page or make a request.
      >
      I'm still stuck with my basic problem of needing to create POST data
      programmaticall y and sending it to PayPall, and ending up on the PayPal
      page I sent the data to. Any ideas?
      It's not too hard - the POST data is just name-value pairs separated by
      ampersands - just like on the query string. Oh, and you have to set the
      content-type to the correct value as well.

      I have an HttpPostRequest class that I threw together that neatly wraps up
      form-style post requests. I'm not at the same location as that code right
      now, but if no one else has posted some code by the end of the day, I'll see
      if I can track down that class & make it available.

      -cd


      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: Creating POST data for Server.Transfer ()?

        Carl Daniel [VC++ MVP] wrote:
        "David Veeneman" <dcv@nospam.com wrote in message
        news:O4H6hcqAHH A.5068@TK2MSFTN GP02.phx.gbl...
        >My bad. Server.Transfer won't call an external page or make a
        >request. I'm still stuck with my basic problem of needing to create POST
        >data
        >programmatical ly and sending it to PayPall, and ending up on the
        >PayPal page I sent the data to. Any ideas?
        >
        It's not too hard - the POST data is just name-value pairs separated
        by ampersands - just like on the query string. Oh, and you have to
        set the content-type to the correct value as well.
        >
        I have an HttpPostRequest class that I threw together that neatly
        wraps up form-style post requests. I'm not at the same location as
        that code right now, but if no one else has posted some code by the
        end of the day, I'll see if I can track down that class & make it
        available.
        I was about to post the code and then I realized that I think you're asking
        for something else. If I'm reading you right, you're writing code that's in
        the code-behind (beside, inline, whatever) for an ASP.NET page and you need
        to do a POST to PayPal and have the user's browser end up viewing the page
        that PayPal returns. Is that right?

        If that's what you're after, then the way to do it is to enlist the help of
        the user's browser. Have your ASP.NET page return a page with a pre-filled
        <form(all elements can simply be <input type="hidden">) and use
        client-side JScript to post that form in the client-side page load event.
        That way, the user's browser actually makes the post & displayes the results
        just like the user expects.

        -cd


        Comment

        • Göran Andersson

          #5
          Re: Creating POST data for Server.Transfer ()?

          David Veeneman wrote:
          I want to programmaticall y create some POST data on a web server, then pass
          that data to another web page that the server calls, using
          Server.Transfer (). What's the best way to do that?
          >
          I'm programming some buttons that link to PayPal's shopping cart. The
          shopping cart needs a bunch of data about the item being added, including
          price. PayPal's sample markup puts the data in a hidden form, which the
          button submits.
          >
          I'm concerned about the lack of security in that approach, so I want to have
          the button invoke a method on the server that will assemble the POST data
          that PayPal needs, and then redirect to PayPal. Right now I have a 'button
          dispatch' page, which contains the data assembly and redirect
          (Server.Transfe r()) code in its Page_Load event.
          >
          What I can't figure out is how to get the POST data into the Request the
          page will submit when it redirects to PayPal. What's the simplest way to do
          this? Are there any examples? Thanks much.
          >
          David Veeneman
          Foresight Systems
          >
          I have replied to this in a different newsgroup.

          If you make a proper cross post instead of posting separate copies, you
          will get a single thread instead of separate confused threads.

          Comment

          Working...