Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Anders 4 posts 75 karma points
    Mar 21, 2019 @ 09:27

    BeginUmbracoForm changes route value


    I'm trying to redirect a partial view form post to a specific method in a controller. But it sees like Umbraco ignores my route and changes it to another route.

    The button on the main page triggering the modal:

    <button class="btn btn-primary" type="button" onclick="OpenCustomerForm()">New Customer</button>

    The script for this page:

    var urlApiController = '@Url.Action("Modal", "CustomerListApi")';
    function OpenPatientForm(customerId) {
            url: urlApiController,
            type: 'POST',
            data: {
                Id: customertId
            success: function (value) {
            error(e) {

    My controller:

     public class CustomerListApiController : SurfaceController
         public PartialViewResult Modal(int? Id)
               //Do stuff
               return PartialView("Partials/Modals/_AddCustomer", myModel);
        public ActionResult SaveCustomer(Customer pCustomerModel)
              //Do stuff

    My View:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<My Customer Model>
    @using (Html.BeginUmbracoForm("SaveCustomer", "CustomerListApi", FormMethod.Post, new { @enctype = "multipart/form-data", @id ="customerForm", @class = "needs-validation", @novalidate = "novalidate" }))
         @* Input fields*@
         <div><button type="submit" class="btn btn-success" id="btnSave">Save</button></div>
    1. I click the button to open the form
    2. The method Modal in my controller get hit and return my form as a partial view and displays it to the user.
    3. When I inspect the html rendered for the form I expected the route for the form to be something like "CustomerListApi/SaveCustomer" as I thought that this was the route that I set in Html.BeginUmbracoForm. But the html is: action="/umbraco/Surface/CustomerListApi/Modal"

    4. I click Save and ends up in Modal in CustomerListApi instead of SaveCustomer.

    Any suggestions of where I'm wrong?


  • Damien Holley 129 posts 428 karma points
    Dec 05, 2019 @ 00:59
    Damien Holley

    +1 to this, the most I have heard about this problem is that there is something up with the routes when you use AJAX/JQ to get a partial view that causes all of the umbracoform routes to go wrong.

    I have yet to figure out an answer.

Please Sign in or register to post replies

Write your reply to: