|
-
April 29th, 2008, 10:01 AM
#1
using method POST
Hi...
I'm trying to send parameters from one page to another in my web application but using method POST... here is what i do:
Page1.aspx, when i click "Send" imagebutton:
Code:
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "descServicio=" + cmb1.Text + "&importe=" + txtTotal.Text;
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost:1513/myApp/page2.aspx");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
Page2.aspx, onPageLoad:
Code:
foreach (string var in Request.Form)
lblMensaje.Text += Request.Form[var] + ";";
it does trigger onPageLoad event on Page2, but web browser stays on Page1 and it doesn't redirect to Page2, why?
if i add Response.Redirect("~/Page2.aspx"); on Page1 it becomes a mess! it does redirect but i lose postData info...
i'm thinking saving the postData info in a Session variable instead, but i'm still wondering if i can solve my problem by using method POST...
thanks in advance...
Last edited by PeejAvery; April 29th, 2008 at 02:29 PM.
Reason: Added code tags.
-
April 30th, 2008, 09:34 AM
#2
Re: using method POST
i need to get this done because i have to send that info to a bank web site via method post, they'll receive my info, display another page and ask for more info to the end user, then the bank will process all gathered info and go back to my web site...
this has been working in php but now i have to accomplish it in asp.net but i think asp.net's method POST is not similar to asp's method POST...
any suggestions?
-
April 30th, 2008, 02:56 PM
#3
Re: using method POST
well... for future references..
you have to use imagebutton.postbackurl property to get it done...
and sending your hidden parameters inside <form>
it worked for me...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|