3

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

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

1 Answer 1

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.

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.