Copied to clipboard

Flag this post as spam?

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


  • Moran 277 posts 885 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 11258 posts 23500 karma points MVP 7x 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 3325 posts 11170 karma points MVP 5x 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 4861 posts 12138 karma points MVP 3x 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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies