Copied to clipboard

Flag this post as spam?

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


  • Moran 285 posts 934 karma points
    Jan 25, 2015 @ 06:05
    Moran
    0

    Trying to get a node Id in surface controller

    Hi I am trying to get the node id of my contact page in order to redirect the user to that page after he fills the contact form. using the surface controller I try to get the contact page id using:

    var contactPage = Services.ContentTypeService.GetContentType("ConatctPage");
    

    But I get the wrong id. Is this the right way to use the API? Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 25, 2015 @ 14:57
    Jan Skovgaard
    0

    Hi Moran

    Do you have more than one page based on the "ContactPage" alias? If so then that's probably the reason why you get the wrong id returned?

    /Jan

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Jan 26, 2015 @ 10:40
    Dave Woestenborghs
    0

    Also I wouldn't use the contenttype service in your controller. This hit's the database directly.

    Better way is to get your site root node. And then do a call to Descendants("ConatctPage").FirstOrDefault() from that node

    Dave

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 26, 2015 @ 12:12
    Jeroen Breuer
    1

    Hello,

    You could also place a content picker on your node and redirect to that node.

    Or if it's a child node on your contact form you could just redirect to the first child node. I do the same in the Hybrid Frameworkhttps://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Controllers/ContactController.cs#L46

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft