title: WFFM form POST and redirect
body: <p>I've roughly followed this example but it doesnt solve my Sitecore-related redirect problem.
  <a href="https://stackoverflow.com/questions/8593799/sitecore-web-form-for-marketers-form-post-to-external-url">sitecore web form for marketers form post to external url</a></p>
  
  <p>I've confirmed that my form POST works properly by using a 3rd party POST test tool. The problem I'm having is that in Sitecore they use a successMode to determine what the user wants todo if the submit is a success. If the user selects successmode/message, the form redirects back to a thank you message. If the user selects successmode/redirect, the success method pipeline looks for the success page value in the form and then a redirect happens to that URL. The problem with the redirect is that it loses my POST data.</p>
  
  <p>Can anyone provide a Sitecore example of how they executed a form POST, and then redirect to the target external URL without losing POST values?</p>
  
  <p>Did you use the successmode settings in the form?</p>
  
  <p>I'm debating whether to overrride the successmode redirect pipeline, add conditions and test but I'm open to a solution that could include jquery.</p>
  
  <p>Here's is my code:</p>
  
  <pre><code>        using Sitecore.Data;
      using Sitecore.Form.Core.Client.Data.Submit;
      using Sitecore.Form.Core.Controls.Data;
      using Sitecore.Form.Submit;
      using System.Web;
      using Sitecore.Web.UI.HtmlControls;
      using Sitecore.Text;
      using Sitecore.Forms.Core.Data;
      using Sitecore.Form.Core.Configuration;
      using Sitecore.Forms.Core.Crm;
      using System;
      using System.IO;
      using System.Net;
      using Sitecore.Diagnostics;
      using System.Text;
  
      namespace XXXWffmExternals
      {
          public class Redirect : ISaveAction      
          {                
              UrlString url = new UrlString("https://XXX.XXX/default.asp");
  
              public virtual void Execute(ID formid, AdaptedResultList fields, params object[] data)
              {
                  String strResult = "";            
                  strResult = setPost(url.ToString(), fields); 
  
              }
  
              public String setPost(string url, AdaptedResultList fieldListForPOST)
              {
                  String resultReturn = "";
  
                  AdaptedControlResult firstname = fieldListForPOST.GetEntry(this.First_Name, "First_Name");
                  AdaptedControlResult lastname = fieldListForPOST.GetEntry(this.Last_Name, "Last_Name");
                  AdaptedControlResult billingaddress = fieldListForPOST.GetEntry(this.Billing_Address, "Billing_Address");
                  AdaptedControlResult billingcity = fieldListForPOST.GetEntry(this.Billing_City, "Billing_City");
                  AdaptedControlResult billingstate = fieldListForPOST.GetEntry(this.Billing_State, "Billing_State");
                  AdaptedControlResult billingzip = fieldListForPOST.GetEntry(this.Billing_Zip, "Billing_Zip");
                  AdaptedControlResult billingphone = fieldListForPOST.GetEntry(this.Billing_Phone, "Billing_Phone");
                  AdaptedControlResult email = fieldListForPOST.GetEntry(this.Email, "Email");
                  AdaptedControlResult amount = fieldListForPOST.GetEntry(this.Amount, "Amount");
                  AdaptedControlResult desc = fieldListForPOST.GetEntry(this.Description, "Description");
                  AdaptedControlResult login = fieldListForPOST.GetEntry(this.Login, "Login");
                  AdaptedControlResult acct = fieldListForPOST.GetEntry(this.Account, "Account");
                  AdaptedControlResult fund = fieldListForPOST.GetEntry(this.Fund, "Fund");
                  AdaptedControlResult org = fieldListForPOST.GetEntry(this.Org, "Org");
  
                  AdaptedControlResult source_code = fieldListForPOST.GetEntry(this.Source_Code, "Source_Code");
  
                  String post =
                      "First_Name=" + firstname.Value +
                      "&amp;Last_Name=" + lastname.Value +
                      "&amp;Billing_Address=" + billingaddress.Value +
                      "&amp;Billing_City=" + billingcity.Value +
                      "&amp;Billing_State=" + billingstate.Value +
                      "&amp;Billing_Zip=" + billingzip.Value +
                      "&amp;Billing_Phone=" + billingphone.Value +
                      "&amp;Email=" + email.Value +
                      "&amp;Amount=" + amount.Value +
                      "&amp;Description=" + desc.Value +
                      "&amp;Login=" + login.Value +
                      "&amp;Account=" + acct.Value +
                      "&amp;Fund=" + fund.Value +
                      "&amp;Org=" + org.Value +
                      "&amp;Invoice_Num=" + "DVXXXX";
  
                  resultReturn = sendPost(url.ToString(), post); 
  
                  return resultReturn;
  
              }
  
              public String sendPost(string url, string post)
              {
  
                  String result = "";
  
                  HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                  objRequest.Method = "POST";
                  // Set credentials to use for this request.
                  objRequest.Credentials = CredentialCache.DefaultCredentials;
  
                  // Convert POST data to a byte array.           
                  byte[] byteArray = Encoding.UTF8.GetBytes(post);
  
                  // Set the ContentLength property of the WebRequest.
                  objRequest.ContentLength = byteArray.Length;
                  // Set the ContentType property of the WebRequest.
                  objRequest.ContentType = "application/x-www-form-urlencoded";
                  // Get the request stream.
                  Stream dataStream = objRequest.GetRequestStream();
                  // Write the data to the request stream.
                  dataStream.Write(byteArray, 0, byteArray.Length);
                  // Close the Stream object.
                  dataStream.Close();
                  // Get the response.
                  WebResponse response = objRequest.GetResponse();                      
                  // Get the stream containing content returned by the server.
                  dataStream = response.GetResponseStream ();
                  // Open the stream using a StreamReader for easy access.
                  StreamReader reader = new StreamReader (dataStream);
                  // Read the content.
                  result = reader.ReadToEnd ();
  
                  // Clean up the streams.
                  reader.Close ();
                  dataStream.Close ();
                  response.Close ();
                  return result;      
  
  
              }
  
  
  
              public string First_Name { get; set; }       
              public string Last_Name { get; set; }       
              public string Billing_Address { get; set; }
              public string Billing_City { get; set; }
              public string Billing_State { get; set; }
              public string Billing_Zip { get; set; }
              public string Billing_Phone { get; set; }
              public string Email { get; set; }
              public string Amount { get; set; }
              public string Description { get; set; }
              public string Login { get; set; }
              public string Account { get; set; }
              public string Fund { get; set; }
              public string Org { get; set; }
              public string Invoice_Num { get; set; }
              public string Source_Code { get; set; }
  
          }
  
  
      }
  </code></pre>