Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Arul Pushpam Murugan 13 posts 103 karma points
    15 days ago
    Arul Pushpam Murugan

    RenderTemplate throws error string

    Hi Team, I have logic to read the node templates. while reading the template page throws an error. the actual issue is I have 10-page nodes. while reading those 10 pages using RenderTemplate() the first page only throws the error remaining 9 pages read the page without issue. but overall API result throws 301 sometime throws 500 error. if I ignore that one error page then the API result gives to resolve it?

    RenderTemplate() always returns a string if it errors message. kindly give the solution

  • David Armitage 347 posts 1373 karma points
    1 week ago
    David Armitage

    Hi Arul,

    I am not sure what you mean here. Please can you provide example of your code and point out where the error is happening so we can try help debug it.



  • Arul Pushpam Murugan 13 posts 103 karma points
    1 week ago
    Arul Pushpam Murugan

    Thank you for your time David.

    this is my code for reading the template

      var **htmlObject** = _umbracoComponentRenderer.RenderTemplate(content.Id);
     return htmlObject != null ? htmlObject.ToHtmlString() : null;

    i send the content id .it return the HTML string.

    for example. , have two content page articles and a product page. article page template doesn't have any errors so it will return the exact document HTML in htmlObject variable.

    while reading the article template I didn't check some of the values with the not null condition in it will throw the error.I get the object reference not set an instance of object error in the htmObject variable.

    my question is how can I get the differentiate the first and second htmObject variable values.

    first one is the correct value, second one is the error string.

Please Sign in or register to post replies

Write your reply to: