Copied to clipboard

Flag this post as spam?

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


  • Scott 69 posts 146 karma points
    Mar 01, 2012 @ 14:29
    Scott
    0

    How can I tell if I'm in preview mode?

    My site is an authenticated website, and we have incorporated some authorization that will only allow certain people to see certain pages. Its all a proprietary setup, something that was in place before we started making the switch to Umbraco. But my problem is my editors can not view a page in preview mode without logging in to the site. Is there a way to detect I am in preview? I've tried the following but none worked:

     

    if (Session["UmbracoLiveEditingMode"] != null && bool.Parse(Session["UmbracoLiveEditingMode"].ToString()))

    if (umbraco.GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)

    if (Page is umbraco.BasePages.BasePage)

    I'm running 4.7.1.

  • Scott 69 posts 146 karma points
    Mar 01, 2012 @ 14:39
    Scott
    3

    Never seems to fail. I look around for hours. I post a question here. Then immediatly I find what I'm looking for. Maybe I should just start asking first :)

    The answer seems to be:

    if (umbraco.presentation.UmbracoContext.Current.InPreviewMode)


  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 01, 2012 @ 14:56
    Tom Fulton
    0

    FYI, you can also check for the existence of the "UMB_PREVIEW" cookie - probably more useful if you need to check from XSLT or somewhere other than .NET though.

  • Scott 69 posts 146 karma points
    Mar 19, 2012 @ 13:45
    Scott
    0

    This is all working fine and I am using the cookie in my XSLT...but then i ran into a snag. My website is an authenticated user website. There are some pieces of information we dont want unauthenticated users to see and we lock down our pages accordingly. I dont want my editors to have to be authenticated to see their pages in preview mode, hence this topic. But at the same time, its super easy to inject a cookie into my browser and someone with any knowledge of umbraco could do so, and see basically everything without logging in. So are there some alternatives? 

Please Sign in or register to post replies

Write your reply to:

Draft