By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Server.Transfer() and POST data

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.