1

I'm using XP 10.1 & XC 10.1

The following way used to work in earlier versions of XP.

using (Ajax.BeginForm("SaveContactUsFormData", "ContactUsForm",
                                new AjaxOptions
                                {
                                    HttpMethod = "Post",
                                    OnSuccess = "OnSuccessContactUs",
                                    OnFailure = "OnFailureContactUs",
                                    LoadingElementId = "divLoading"
                                }))
{    
        @Html.AntiForgeryToken()
    <button type="submit">Submit</button>
}

But now it renders the form action url as - /api/cxa/ContactUsForm/SaveContactUsFormData
I'm expecting the url should be - /api/sitecore/ContactUsForm/SaveContactUsFormData. Is that correct or has it changed for commerce (or xp 10.1).

The controller method is not triggered on debug and the button click is doing a postback instead of an asynchronous call.

UPDATE:

The code in the action method does execute without any errors.

3
  • Yes it is correct, OOTB calls will go through api/cxa but if you want to change you need to use routing May 5 at 4:15
  • Also can you check Network tab of browser and see what is the output of this call? May 5 at 4:26
  • @GauravAgarwal But the default /api/cxa is not hitting the controller method. When you say "if you want to change.." is there any way to still make it work without changing route or what would be the solution. Thank you.
    – Qwerty
    May 5 at 5:35
3

Set "IsCxaSite" to true in "Site Grouping" item for that SXA site and then try to trigger cxa api's.

enter image description here

3
  • It is already set to true.
    – Qwerty
    May 5 at 6:31
  • Does Controller which you are try to hit inherit SXA's StandardController?
    – Akash S
    May 5 at 6:42
  • It's System.Web.Mvc Controller. The breakpoint is not hit and also the button click is doing a postback. Surprisingly, the code in the controller method is executed fine and data getting saved.
    – Qwerty
    May 5 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.