2

I am trying to submit a form through an ajax process :

 @using (Ajax.BeginForm("SendEmail", "Form", new AjaxOptions
        {
            UpdateTargetId = "replace",
            InsertionMode = InsertionMode.Replace,
            HttpMethod = "Post",
        }))
        {
         // the form details
        }

the action for this form is defined in the Form controller as:

[HttpPost]
 public ActionResult SendEmail(EnquiryFormViewModel model)
        {
           _sendForm.SendFormByEmail(model.FirstName, model.Surname, model.Email, model.NatureOfEnquiry,model.Message);
            return PartialView("EmailResult", model.FormMetaData);
        }

The route is defined in the global.asax as:

  //Form button
            routes.MapRoute(
                name: "FormButton",
                url: "Form/{action}",
                defaults: new { controller = "Form", action = "SendEmail" }
                ).DataTokens.Add("area", "Core");

The action is supposed to return a partial page that contains some information about the successful submission of the form and thanking the user. However, as soon as the button is clicked, I get a 404 error that Requested URL: /Form/SendEmail is not available. The action method is executed, but I can't get the page that I am supposed to get through the action. How can I fix this?

2
  • Is this question specific to Tridion/DXA, or is it a general question about ASP.NET MVC. If it's the latter, stackoverflow is probably a better bet. Commented Apr 29, 2016 at 15:58
  • @DominicCronin the question is with in the context of Tridion/DXA. It would be very simple to do this in normal ASP.Net MVC. But, somehow in the DXA it is not working.
    – Payam
    Commented Apr 29, 2016 at 16:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.