snipt

Ctrl+h for KB shortcuts

C#

Issue with preview content in

1
2
3
4
5
6
7
//This used to work to get preview content but throws an error now.
//Still works with published content.
// EAVB_SWQOKRGRDG

var contentApi = new Ektron.Cms.Framework.Core.Content.Content();
contentApi.InPreviewMode = (cmsMode == CmsMode.Preview);
return contentApi.GetItem(id);
https://snipt.net/embed/22da891452b40b6a904d2624b4362301/
/raw/22da891452b40b6a904d2624b4362301/
22da891452b40b6a904d2624b4362301
csharp
C#
7
2019-06-13T06:26:33
True
False
False
/api/public/snipt/15570/
issue-with-preview-content-in
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//This used to work to get preview content but throws an error now.</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">//Still works with published content.</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">// EAVB_SWQOKRGRDG</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="kt">var</span> <span class="n">contentApi</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Ektron</span><span class="p">.</span><span class="n">Cms</span><span class="p">.</span><span class="n">Framework</span><span class="p">.</span><span class="n">Core</span><span class="p">.</span><span class="n">Content</span><span class="p">.</span><span class="n">Content</span><span class="p">();</span> </span><span id="L-6"><a name="L-6"></a><span class="n">contentApi</span><span class="p">.</span><span class="n">InPreviewMode</span> <span class="p">=</span> <span class="p">(</span><span class="n">cmsMode</span> <span class="p">==</span> <span class="n">CmsMode</span><span class="p">.</span><span class="n">Preview</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="k">return</span> <span class="n">contentApi</span><span class="p">.</span><span class="n">GetItem</span><span class="p">(</span><span class="n">id</span><span class="p">);</span> </span></pre></div> </td></tr></table>
content, ektron