'Page shown after the form has been sent' is on each Xform Editor and I just want to do manual sending another mail after the Xform mail has been sent and then after I sent manual mail, it redirect to the page which I have setted.
I really need your help.
I researched a lot, but cannot find any useful information. Then I reflector the source and according to episerver 7 codes, finally solve the problem.
Would be nice if you could share some code fragments for reference. Thanks!
In EPiServer.dll the following code exists in the class-file XFormSuccessACtionResult.cs that contributes to the problem.
If the editor have an confirmation page, the Success method isn't invoked.
public override void ExecuteResult(ControllerContext context) { if (base.XForm.PageGuidAfterPost != System.Guid.Empty) { string mappedUrl = this.GetMappedUrl(base.XForm); if (!string.IsNullOrEmpty(mappedUrl)) { context.HttpContext.Response.Redirect(mappedUrl); } } else { base.InvokeAction(context.Controller as Controller, context.HttpContext.Request.Params.get_Item("successAction")); } }
There is a work around. After I did some decompiling of the EPiServer.dll I came up with this solution (assuming that you use DoSubmit as PostAction and Success as the SuccessAction)
[AcceptVerbs(HttpVerbs.Post)] public virtual ActionResult Success(BasePageData currentPage, XFormPostedData xFormpostedData) { //you custom code here ... //Return to the right page.. if(xFormpostedData.XForm.PageGuidAfterPost != Guid.Empty) { return Redirect(UrlResolver.GetUrl(ContentRepository .Get<PageData>(xFormpostedData.XForm.PageGuidAfterPost) .ContentLink)); } //default, return to index. return View(currentPage); } [AcceptVerbs(HttpVerbs.Post)] public virtual ActionResult DoSubmit(BasePageData currentPage, XFormPostedData xFormpostedData) { if (ModelState.IsValid && ProcessXFormAction(xFormpostedData)) return Success(currentPage, xFormpostedData); return ServiceLocator.Current .GetInstance<XFormPageUnknownActionHandler>() .HandleAction(this); } protected bool ProcessXFormAction(XFormPostedData post) { var xformData = new XFormPageHelper().GetXFormData(this, post); try { return XFormActionHelper.DoAction(xformData, post, true); } catch (Exception ex) { this.ModelState.AddModelError("ProcessXFormAction", ex.Message); return false; } }
Hi ,
I am now using Episerver 7 MVC to create some Xform for sending mail or redirect to other page much more convenient.
But after research in the internet and forums as well, I found a solution to let the form work. But there still a question cannot to solve. If I not choose the brower 'Page shown after the form has been sent', the Success Action could be triggered, but if I choose a page for the brower option, Success action could not be fired and just redirect to the page which I have chosen in Episerver CMS.
I want to know how to deal with it and if I want to use AfterSubmitPostedData event in Episerver 7 MVC, how can I do?
Just the same as in global.asax or just do not have to do it and use other action instead.