472,127 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Server.Transfer() and POST data

I am creating a form on the server that I want to POST to a URL that's being
called with Server.Transfer(). What's the simplest way to do that?

A little background: I'm programming buttons that link to PayPal's shopping
cart. PayPal wants an HTML form with data about the product selected
(including price), and they provide sample HTML to create a hidden form to
transmit the data when the 'Add to cart' button is clicked.

It would be absurdly easy for a hacker to change the price from $100 to $1
or defraud the site in other ways. So, rather than linking to PayPal, I want
to
link the 'Add to cart' button to a page that runs on my server and never
downloads to the user's browser.

The 'Add to cart' button passes just the item number to a server page, which
calls a C# method in its Form_Load event. The method will programmatically
create the form data that will be set as POST data. The method then calls
Server.Transfer() to pass control to PayPal's shopping cart.

So, what's the simplest way to assemble the data? I'd like to create it as a
NameValueCollection, and then call something which sets it as POST data
for the Request that's passed when I call Server.Transfer(). Is that
possible?
Are there examples of how to do this? Thanks.

David Veeneman
Foresight Systems
Nov 7 '06 #1
3 3864
David Veeneman wrote:
I am creating a form on the server that I want to POST to a URL that's being
called with Server.Transfer(). What's the simplest way to do that?

A little background: I'm programming buttons that link to PayPal's shopping
cart. PayPal wants an HTML form with data about the product selected
(including price), and they provide sample HTML to create a hidden form to
transmit the data when the 'Add to cart' button is clicked.

It would be absurdly easy for a hacker to change the price from $100 to $1
or defraud the site in other ways. So, rather than linking to PayPal, I want
to
link the 'Add to cart' button to a page that runs on my server and never
downloads to the user's browser.

The 'Add to cart' button passes just the item number to a server page, which
calls a C# method in its Form_Load event. The method will programmatically
create the form data that will be set as POST data. The method then calls
Server.Transfer() to pass control to PayPal's shopping cart.

So, what's the simplest way to assemble the data? I'd like to create it as a
NameValueCollection, and then call something which sets it as POST data
for the Request that's passed when I call Server.Transfer(). Is that
possible?
Are there examples of how to do this? Thanks.

David Veeneman
Foresight Systems
You can't use Server.Transfer to execute a page on a different server.
Server.Transfer does not send a request.

You can use the WebRequest or WebClient classes to make the request.
Nov 7 '06 #2
Thanks. I can see how to use those classes to send values to a PayPal page,
but how do I go about loading PayPal's response as the current web page?
Most of the methods appear to return the response as a byte array.
Nov 7 '06 #3
David Veeneman wrote:
Thanks. I can see how to use those classes to send values to a PayPal page,
but how do I go about loading PayPal's response as the current web page?
Most of the methods appear to return the response as a byte array.
Use Response.BinaryWrite to send the response in binary format.
Nov 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by StephenMcC | last post: by
4 posts views Thread by Mathew | last post: by
3 posts views Thread by Manuel Lopez | last post: by
9 posts views Thread by Steve Buster | last post: by
4 posts views Thread by Piotr Strycharz | last post: by
11 posts views Thread by Alexander Bosch | last post: by
23 posts views Thread by barryfz | last post: by
4 posts views Thread by David Veeneman | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.