Copied to clipboard

Flag this post as spam?

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

  • Anders 2 posts 73 karma points
    Mar 25, 2019 @ 07:43

    BeginUmbracoForm, how to route to right action

    I'm trying to submit my form to "NewCustomer" action in "CustomerListApiController"

    This is where I'm trying to route my form

    Html.BeginUmbracoForm("NewCustomer", "CustomerListApi",  FormMethod.Post, new { @enctype = "multipart/form-data")

    I have a button of type="submit"

    When you click the "Open form" button on my page an Ajax-post is triggered to the "Modal" Action in "CustomerListApiController". The method returns the requested data and a modal with the form is shown on the page. But when I inspect the form element it says that it wants to post to "Modal" action again. Despite that I've specified "NewCustomer" in BeginUmbracoForm.

    My controller

    public class PatientListApiController : SurfaceController
            public ActionResult NewCustomer(CustomerBE pCustomerBE)
                 //Do Stuff
            public PartialViewResult Modal(int? Id)
                 //GetData and return model for rendering the form in a modal

    What I'm I doing wrong?

  • AddWeb Solution Pvt. Ltd 43 posts 197 karma points
    Mar 25, 2019 @ 08:03
    AddWeb Solution Pvt. Ltd

    Your controller has 2 methods, 1 for showing the form ShowForm and 1 for the business logic that is executed after the submit button is pressed HandleFormPost

    All the routing information is in the following statement


    Html.BeginUmbracoForm is only a wrapper around Razors own Html.BeginForm with some additional functionality for routing.

    The above statement creates something like

    For more explanation on creating a form using MVC, check out this article

Please Sign in or register to post replies

Write your reply to: