Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

MVC XForm troubles


I'm experimenting a bit with XForms, both on a page, and in a block.

So far I have managed to get the postings to work from both, by a bit of trickery, but for some reason, the default rendering of the action attribute does not include the current language branch, so all postings go to the master language version. Am I missing something? I'd rather not start writing a workaround, if there'se nothing to work around :)


Feb 07, 2013 9:49

Probably pretty late reply. But anyway for reference:

I found it useful to write form action Url to the view model in controller (for instance):

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var pageUrl = urlResolver.GetVirtualPath(currentPage.ContentLink);
var actionUrl = string.Format("{0}XFormPost/", pageUrl);
actionUrl = UriSupport.AddQueryString(actionUrl, "XFormId", viewModel.Form.Id.ToString());
actionUrl = UriSupport.AddQueryString(actionUrl, "failedAction", "Failed");
actionUrl = UriSupport.AddQueryString(actionUrl, "successAction", "Success");
viewModel.ActionUrl = actionUrl;


And then write XForm using BeginXForm method:

@using (Html.BeginXForm(Model.Form, new { Action = Model.ActionUrl }))



More info about how to host in blocks:

Aug 21, 2013 10:02

There's a slightly updated version of the above mentioned blog post here:

Aug 21, 2013 17:48

Ah, good to know :)

Aug 21, 2013 21:16
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.