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 16 posts 108 karma points
    Jul 30, 2020 @ 12:04
    Arul Pushpam Murugan
    0

    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 success.how to resolve it?

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

  • David Armitage 508 posts 2078 karma points
    Aug 01, 2020 @ 03:02
    David Armitage
    0

    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.

    Regards

    David

  • Arul Pushpam Murugan 16 posts 108 karma points
    Aug 01, 2020 @ 04:31
    Arul Pushpam Murugan
    0

    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.so 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:

Draft