Questions on XForm MVC 4 Sending Mail Success or Failed in Episerver 7

Vote:
 

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.

#73812
Aug 11, 2013 17:37
Vote:
 

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

#73813
Aug 11, 2013 17:42
Vote:
 

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.

#73899
Aug 14, 2013 5:40
Vote:
 

Would be nice if you could share some code fragments for reference. Thanks!

#74446
Aug 28, 2013 9:00
Vote:
 

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"));
}
}



#121955
May 21, 2015 18:05
Vote:
 

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;
    }
}
#122649
Jun 09, 2015 10:06
Vote:
 

This save my day!

Very useful information

#141985
Nov 25, 2015 14:46
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.