1

We are getting the below error in Sitecore Forms on Production site. enter image description here

We are using Sitecore 9.1.1 version with SXA.

I went through many articles/blogs but could not find anything relevant Please suggest.

5
  • Did you check this article related to the caching? madhuanbalagan.com/… Commented Jul 5, 2022 at 15:22
  • I have already checked this link and we are not using cache in our site.
    – Nisha
    Commented Jul 5, 2022 at 15:31
  • Did you verify whether anti forgery token is generated by inspecting the form in browser Dev tools. If yes, is token is changing on every refresh? If token itself is not generated, then you have to check the Form.cshtml. @Html.AntiForgeryToken() line should be presented.
    – Thamizh
    Commented Jul 5, 2022 at 15:52
  • I have checked all the details and found that token is changing after refreshing the page. Is it possible to get this error after getting 500 error?
    – Nisha
    Commented Jul 5, 2022 at 18:22
  • Are you getting 500 error. Did you check event viewer for further details?
    – Thamizh
    Commented Jul 8, 2022 at 6:06

3 Answers 3

1

If the web.config file has the correct settings for the AntiForgery token, then you should verify that the ValidateAntiForgeryToken attribute is present in the controller responsible for form submission. Additionally, you should ensure that @Html.AntiForgeryToken() is present in the form view.

1

I have disabled the field caching section for rendering items associated with the page. Despite this, I encountered the same issue. Upon further investigation, I discovered that disabling the following three fields resolved the issue:

  • Cacheable [shared]
  • Clear on Index Update [shared]
  • Vary By Data [shared]
0

The way Anti-Forgery works in Sitecore is the following:

  1. There should be @Html.AntiForgeryToken() HTML helper in the form razor view
  2. A validation should be made in the forms controller using the [ValidateAntiForgeryToken] action filter

If you have these then an HTML code should be generated like below:

<input name="__RequestVerificationToken" type="hidden" value="xxxx">

Although the blog is about implementing forms in JSS, the concept could be understood from this link: Sitecore JSS Anti-forgery

Your Answer

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

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