2

I need to update page renderings based on search results using ajax call. I have written a method to get rendering collection based on filter and when I call Html.Sitecore().Rendering via loop in view like below:

@Html.Sitecore().Rendering("{450270A9-640A-46B4-80ED-02CCCCCB2549}", new { DataSource = "{C3D52B5F-F236-49DF-A027-6432FE2F80FE}" })

I get an error - "Object reference not set to an instance of an object" only for ajax call but above code works for page request. I researched about this issue and I didn't get any solution.

Is it possible to call Html.Sitecore().Rendering using Ajax

enter image description here

enter image description here

  • 1
    Post the full stack trace of that exception, please. – Mark Cassidy Sep 30 '17 at 8:38
  • @MarkCassidy - Posted stack exception – User464 Sep 30 '17 at 14:37
3

I found the solution @Html.Sitecore().Rendering() will not work for View rendering type. My rendering was of type View rendering which it was throwing above error.

And also I tried with @Html.Sitecore().ViewRendering() for view rendering type, it dint work as expected.

So I decided to use Controller rendering to make it work.

| improve this answer | |

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.