CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Aug 2007
    Posts
    47

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured