Post 数据到营销人员 Sitecore 8 的自定义保存操作 Web 表单中的下一页
Post Data to next Page in Custom Save Action Web Form For Marketer Sitecore 8
在 WFFM 自定义保存操作中保存数据后,我想重定向包含大量数据的成功页面
我正在尝试下面的代码行。
我可以使用 Cookie、会话或查询字符串和 Response.Redirect(baseUrl),但我想使用 Cookie、会话或查询字符串。
class SaveAction : WffmSaveAction
{
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext, params object[] data)
{
//Save Data in Service ,, Redirect to success page with below code with some data like ID
string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/success-page";
HttpContext.Current.Response.Clear(); //
StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
sb.AppendFormat("<form name='form' action='{0}' method='post'>", baseUrl);
sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", "123456");
// Other params go here
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");
HttpContext.Current.Response.Write(sb.ToString());
HttpContext.Current.Response.End();
// HttpContext.Current.Response.Redirect(baseUrl);
}
}
以上代码在 Html.
中重新加载没有正文的相同页面
我在给定的代码中遗漏了什么吗?
答案可能取决于您是否拥有 mvc 表单。
如果是 mvc 表单,您可能需要阅读以下内容:http://ggullentops.blogspot.be/2016/07/sitecore-wffm-act-on-success.html。它描述了连接到成功管道 <wffm.success>
并将数据传递到成功页面(究竟如何——查询字符串、会话、.. 取决于你(r 代码))。知道正确的管道后相当容易。
还有一个很棒的 post here 描述了您正在尝试做的事情 - 即保存数据以供以后在 saveaction 中使用。此处复制的代码太多,归结为在保存操作期间保存数据(在会话中)并创建将放置在成功页面上的呈现(以再次读取和处理数据)。
无论如何,创建一个渲染以放置在您的成功页面上是您必须做的事情。不要尝试重定向自己,Sitecore 会为您完成。
在 WFFM 自定义保存操作中保存数据后,我想重定向包含大量数据的成功页面 我正在尝试下面的代码行。
我可以使用 Cookie、会话或查询字符串和 Response.Redirect(baseUrl),但我想使用 Cookie、会话或查询字符串。
class SaveAction : WffmSaveAction
{
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext, params object[] data)
{
//Save Data in Service ,, Redirect to success page with below code with some data like ID
string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/success-page";
HttpContext.Current.Response.Clear(); //
StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
sb.AppendFormat("<form name='form' action='{0}' method='post'>", baseUrl);
sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", "123456");
// Other params go here
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");
HttpContext.Current.Response.Write(sb.ToString());
HttpContext.Current.Response.End();
// HttpContext.Current.Response.Redirect(baseUrl);
}
}
以上代码在 Html.
中重新加载没有正文的相同页面我在给定的代码中遗漏了什么吗?
答案可能取决于您是否拥有 mvc 表单。
如果是 mvc 表单,您可能需要阅读以下内容:http://ggullentops.blogspot.be/2016/07/sitecore-wffm-act-on-success.html。它描述了连接到成功管道 <wffm.success>
并将数据传递到成功页面(究竟如何——查询字符串、会话、.. 取决于你(r 代码))。知道正确的管道后相当容易。
还有一个很棒的 post here 描述了您正在尝试做的事情 - 即保存数据以供以后在 saveaction 中使用。此处复制的代码太多,归结为在保存操作期间保存数据(在会话中)并创建将放置在成功页面上的呈现(以再次读取和处理数据)。
无论如何,创建一个渲染以放置在您的成功页面上是您必须做的事情。不要尝试重定向自己,Sitecore 会为您完成。