简体   繁体   中英

How do I redirect with WebRequest?

I created a WebRequest to POST information. My objective is to emulate in C# a PayPal "buy now" button which is in html.

How do I get the redirect when sending the WebRequest ? Simply having Response.Redirect doesn't work because I have to have the redirect with the information.

The code of the button I'm trying to emulate is:

<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
...
</form>

Not sure you can do what you want from code behind. I had a similar situation where I had the form like yours besides the normal ASP.net form. I hid the non-ASP.net form through CSS so it's not in the user's face and then I triggered the POST via javascript (I put a button inside the form and then called buttonX.click(); )

You can not do redirect with post .

What you can do: Make the actually post direct to the paypal, or redirect to a second page that re-create all the post data, and make automatic post with javascript.

An example of how to create a page with parameters that make automatic post.

http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM