私はこの例に大雑把に従っていますが、私のSitecore関連のリダイレクト問題を解決しません。 sitecore web form for marketers form post to external urlWFFMフォームPOSTとリダイレクト
サードパーティのPOSTテストツールを使用してフォームPOSTが正常に動作することを確認しました。私が抱えている問題は、SitecoreではsuccessModeを使用して、送信が成功した場合にユーザーがしたいことを判断することです。ユーザーがsuccessmode/messageを選択すると、フォームはthank youメッセージにリダイレクトされます。ユーザーがsuccessmode/redirectを選択すると、successメソッドのパイプラインはフォームの成功ページの値を探し、そのURLにリダイレクトが発生します。リダイレクトの問題は、自分のPOSTデータが失われることです。
フォームのPOSTを実行した例のSitecoreの例を提供し、POST値を失うことなくターゲットの外部URLにリダイレクトできますか?
フォームにsuccessmode設定を使用しましたか?
successmodeリダイレクトパイプラインをオーバーライドして条件を追加してテストするかどうかを議論していますが、jqueryを含む可能性があるソリューションには公開されています。
ここにありますが、私のコードです:
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 +
"&Last_Name=" + lastname.Value +
"&Billing_Address=" + billingaddress.Value +
"&Billing_City=" + billingcity.Value +
"&Billing_State=" + billingstate.Value +
"&Billing_Zip=" + billingzip.Value +
"&Billing_Phone=" + billingphone.Value +
"&Email=" + email.Value +
"&Amount=" + amount.Value +
"&Description=" + desc.Value +
"&Login=" + login.Value +
"&Account=" + acct.Value +
"&Fund=" + fund.Value +
"&Org=" + org.Value +
"&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; }
}
}
あなたの懸念を緩和するために... * – foxtrotZulu
コマンドテンプレートが作成され、ベースフォームを複製するように配備されました。したがって、ユーザーが支払いフォームをクリックすると、Webフォームのサイトルートに新しい支払いIDが作成されます。問題は、具体的には外部URLへのPOSTに関することでした。 Btwは、開発者がマーケターのソリューションを提供しなければならない場合や、このようなソリューションに必要なソリューションを提供する必要がある場合には、オーバーライドが一般的なプラクティスです。 WFFMを使わずにフォームタグ内に入力タイプフィールドを作成する方法を教えてください。 – foxtrotZulu
もし私が無礼に出会ったら、私はお詫びします。私は意味しなかった。あなたが尋ねたことに基づいて、基本的にフォーム提出を処理し、WFFMの機能を使用しないようにあなた自身のコードをすべて書いているように思えました。 – divamatrix