5

We recently moved from Sitecore 7.2 to 9.0.2 and since then we have started getting following error when we try to add a control(by clicking "Add here") with datasource from the experience editor. This is only happening on the 9.0.2 instance of Sitecore. Ours is not a MVC project. Just simple web forms. This happens on clicking either the first or the second Add here on the page. We are not referencing Prototype.js in the project so not sure if putting jQuery into No-conflict mode will help. Also, we are able to add controls with datasource by going to presentation details of the page in Sitecore. Any help is greatly appreciated.

What I have tried:

We are not referencing Prototype.js in the project so not sure if putting jQuery into No-conflict mode will help. Also, we are able to add controls with datasource by going to presentation details of the page in Sitecore. I also tried to create a new control(rendering) but it did not help. Adding/removing allowed controls of the placeholder also did not help. I tried removing all JS references from the layout one by one and it did not help sadly.

Below are the screenshots of the error I am getting.

enter image description here

Error in JS.

enter image description here

0

The issue was that in Sitecore 9, when a user adds a control on a page using the Experience Editor, on the final add button click (after providing a datasource) is treated as a POST event. In Sitecore 7.2, it was a GET request.

We had some code written in our backend (.cs file) which was looking to see if it a POST type of request and if yes, redirect to a different page. Like below.

if (Request.HttpMethod == "POST")
{
 //redirect to a different page
}

I added a check here to only run this code when user is NOT in Experience Editor mode like below.

if (Request.HttpMethod == "POST" && !Repository.IsUserEditting())
{
 //redirect to a different page
}

This fixed the issue.

Thanks. Let me know if anyone has any questions.

  • Nice catch, this happened to me too! – MikeD Apr 2 at 14:17

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.