Copied to clipboard

Flag this post as spam?

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


  • Hardy Wang 91 posts 112 karma points
    Jun 08, 2012 @ 17:55
    Hardy Wang
    0

    Is there a property or API tells a node is in preview mode

    I have a piece of Razor code which will inspect URL, in normal page view mode it works fine. But in preview mode all the URL has is http://my-server/node-id.aspx so my Razor code won't work this way.

    One idea is to bypass certain logic in preview mode in the Razor code. Anyone knows can I determine if a displaying is in preview mode or not?

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jun 09, 2012 @ 09:56
    Lee Kelleher
    0

    Hi Hardy,

    When you are in preview mode a cookie is set called "UMB_PREVIEW" ... you could test if that cookie has a value?

    I'm not sure what the exact Razor code is to do that, sorry.

    Cheers, Lee.

  • Simon Dingley 1474 posts 3451 karma points c-trib
    Jun 09, 2012 @ 17:46
    Simon Dingley
    1

    You can probably just use something as simple as the following to check the value?

    Request.Cookies["UMB_PREVIEW"].Value
  • Hardy Wang 91 posts 112 karma points
    Jun 13, 2012 @ 18:07
    Hardy Wang
    0

    Thanks for the information.

  • Marc Meul 2 posts 24 karma points
    Jun 21, 2012 @ 19:36
    Marc Meul
    2

    Or you can use:

    UmbracoContext.Current.InPreviewMode

  • 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