Server.Transfer() and POST data

D

David Veeneman

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

David said:
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.
 
D

David Veeneman

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

=?ISO-8859-1?Q?G=F6ran_Andersson?=

David said:
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.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top