MVC - How to handle XForm posts

Vote:
 

Trying to post an XForm and all I'm getting is 404.

Trying to use code similar to what is found in this thread, http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=64533&pageIndex=2

// Controller

public class StandardController : PageControllerBase<StandardPage>
  {
    private readonly XFormPageUnknownActionHandler _xFormPageUnknownActionHandler;

    public StandardController()
    {
      _xFormPageUnknownActionHandler = new XFormPageUnknownActionHandler();
    }

    [HttpGet]
    public ActionResult Index(StandardPage currentPage)
    {
      return View(currentPage);
    }

    [HttpPost]
    public ActionResult XFormFailed(StandardPage currentPage, XFormPostedData xFormPostedData)
    {
      return View("Index", currentPage);
    }

    [HttpPost]
    public ActionResult XFormPost(XFormPostedData xFormPostedData)
    {
      return _xFormPageUnknownActionHandler.HandleAction(this);
    }

    [HttpPost]
    public ActionResult XFormSuccess(StandardPage currentPage, XFormPostedData xFormPostedData)
    {
      return View("Index", currentPage);
    }

  }

// View

@Html.PropertyFor(model => model.MainForm, new
{
  XFormParameters = new XFormParameters
  {
    PostController = "Standard",
    SuccessAction = "XFormSuccess",
    FailedAction = "XFormFailed",
    PostAction = "XFormPost"
  }
})

Could someone explain how the process of taking care of XForms works, so I understand it? It's hard to write code for things you don't know. =)
#79229
Dec 11, 2013 11:39
Vote:
 

How does the form render? (what's the value of the action attribute).

I usually create a partial for my XForm:

@using EPiServer.XForms.Util
@model EPiServer.XForms.XForm

@Html.ValidationSummary()
@Html.DisplayForModel(new { XFormParameters = new XFormParameters { SuccessAction = "Success", FailedAction = "Failed", PostAction = "DoSubmit" } })

   And then just include it using Html.RenderPartial:

<div class="span6 offset3" @Html.EditAttributes(m => m.CurrentPage.XForm)>
    @{ Html.RenderPartial("_XFormPartial", Model.CurrentPage.XForm); }
</div>

  Frederik 

#79238
Dec 11, 2013 13:46
Vote:
 

The action attribute looks like this,

/help-pages/new-user/XFormPost/?XFormId=a4cff1b7-89e9-4ec2-99ce-2e8786951153&postAction=XFormPost&postController=Standard&failedAction=XFormFailed&successAction=XFormSuccess

#79245
Edited, Dec 11, 2013 15:23
Vote:
 

Any help with this?

I have no idea how to solve this and I could really need help from you EPi wizards. =)

#79412
Dec 16, 2013 21:32
Vote:
 

Bumping this because I'm still stomping at place with this issue.

#79796
Jan 07, 2014 12:43
Vote:
 

Not sure if this will help.

[HttpPost]

public ActionResult XFormPost(XFormPostedData xFormPostedData)

{

    return new _xFormPageUnknownActionHandler.HandleAction(this);

}

 

#84509
Apr 02, 2014 17:42
Vote:
 

Any solution for this? also gets the following 404:

XFormPost/?XFormId=cea6ef99-cbbf-448d-977b-6ab22057410e&postAction=XFormPost&postController=&failedAction=Index&successAction=Index&contentLink=

We have upgraded to EpiServer 10.4.20, can we still use xforms?

#175930
Mar 06, 2017 18:55
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.