Tough redirection question

D

Dot net work

Hi,

Is it possible to do a form POST and also redirect to a different url,
using code behind?

I don't think response.redirect will work because that doesn't post
form data.
I don't think server.transfer will work because that doesn't redirect
to a different url.
I don't think HttpWebRequest will work because that doesn't redirect
to the url, it only posts data to it.

I want to have an code behind asp.net button called "Pay", and when
you click on it, it redirects to a credit card payment site, with the
form's data posted to this website, such as the total amount, etc,
etc.

The cc payment site expects an old fashioned form post btw.

Is a code behind solution not possible?

Thanks for any expert opinion.

-dnw.
 
D

Dan Brussee

The limitation of one form on an ASP.NET page is limited only to those
that you wish to control via ASP.NET. I would suggest putting in a
normal HTML form with an action to wherever you want and a method of
POST. No server side interaction will be done - and I assume this is
what you want.
 
S

Steve C. Orr [MVP, MCSD]

Here's some ideas for you.
1) Output an old fashioned non-server form to the client (without the runat=
'server' attribute) Set the action attribute like you would have in
ASP.OLD, and use javascript to submit the form.
2) use client side script to change your ASP.NET form action attribute
3) use this webform control: http://www.wilsondotnet.com/Controls/
 
D

Dot net work

Hi,

Much appreciate all replies.

Under the asp.net "Pay" button, I think I might need a mixture of code
behind and client side programming?

ASPNET_Pay_Button_Click
If the user needs to do something different then
response.redirect("Another server side aspx form") 'In other words,
carry on doing typical asp.net server side type activities
else if the user wants to go ahead and pay me then
redirect and post some data using the asp.old way to a payment
website
else
'more code behind programming goes here.

Is it possible to get any of your client side suggestions inside the
code behind pay button so that I can post and redirect to the payment
website?

(I'd buy the component mentioned, but I haven't got a spare $50 at the
moment.)

-dnw.
 
D

Dot net work

I think I've done it. (Critical comments are very welcome.)

Under the asp.net "Pay" button, you can have the following code behind
code:

ASPNET_Pay_Button_Click
If the user needs to do something different then
response.redirect("Another server side aspx form") 'In other words,
just carry on doing typical asp.net server side type activities
else if the user wants to go ahead and pay me then
Response.Write("<form name='Form1' action='http://www.domain.com'
method='POST' >")
Response.Write("<input type='hidden' name='SomeDataThatNeedsPosting'
value='12345' >") 'The nice thing about this is that you can
construct the html values at run time using code behind.
Response.Write("</form>")
Response.Write("<script>")
Response.Write("document.Form1.submit();")
Response.Write("</script>")
else
'more code behind programming goes here.

Thank you for all help.

-dnw.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top