Imagine being paid to improve your favorite CMS!

It could be you! Umbraco HQ are hiring and are looking for both talents and senior developers. Wonderful workplace, friendly colleagues and competitive salary.

Copied to clipboard

Flag this post as spam?

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

  • Marc-at 2 posts 72 karma points
    Aug 11, 2017 @ 12:46

    Template ID int is always one too low

    Whenever I request a TemplateID of a node it always returns the correct ID, minus one.

    For example: my homepage has ID 1056, but when I try to display it in my view it returns ID 1055..This happens with all document types.

    I currently use this to fix:

    int currentPageId = Model.Content.TemplateId + 1; //dirty hack

    Does anyone have a fix so I don't have to rely on hardcore maths like the hack above? ;)

  • Nik 477 posts 1848 karma points
    Aug 11, 2017 @ 13:06

    Hi Marc,

    The TemplateID and the NodeID are two different things.

    Looking at the code you are after you want to change your code to Model.Content.Id instead of TemplateId.


Please Sign in or register to post replies

Write your reply to: