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?
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?
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.
You can probably just use something as simple as the following to check the value?
Thanks for the information.
Or you can use:
UmbracoContext.Current.InPreviewMode
is working on a reply...