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

Creating POST data for Server.Transfer()?

P: n/a
I want to programmatically 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.Transfer()) 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

Nov 7 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
programmatically and sending it to PayPall, and ending up on the PayPal page
I sent the data to. Any ideas?
Nov 7 '06 #2

P: n/a
"David Veeneman" <dc*@nospam.comwrote in message
news:O4**************@TK2MSFTNGP02.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
programmatically 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
Nov 7 '06 #3

P: n/a
Carl Daniel [VC++ MVP] wrote:
"David Veeneman" <dc*@nospam.comwrote in message
news:O4**************@TK2MSFTNGP02.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
programmatically 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
Nov 8 '06 #4

P: n/a
David Veeneman wrote:
I want to programmatically 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.Transfer()) 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.
Nov 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.