0

how to create a button in Sitecore SXA which would call a controller action or a rest Api ?

would it be through javascript or is there an ootb feature in SXA , where i could get the user and item context ?

4

This question is not SXA specific question. It's Sitecore MVC question.

You can see how it's done for Login, Logout renderings. Both of them use Html.BeginForm() helper. The disadvantage of this is that page will reload once you click submit button. At the same time, it is good because there is security protection (@Html.AntiForgeryToken()) against cross-site request forgery.

Another way would be JS call (AJAX Request) but there is no snippet for that in the SXA code.

You should review the answers for those keywords: "call controller action sitecore mvc"

I am sure you will find something.

  • Best way to utilise the Ajax call for controller method – Amit Kumar Feb 17 at 10:21

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.