U4-1614 - Preview state remains for content editors until logout

Created by Andreas Iseli 31 Jan 2013, 15:33:01 Updated by cat 01 Jun 2015, 11:58:33

Depends on: U4-793

When editing a content page, opening the preview (using MVC Templates) and closing the preview, the changed content is also visible on the published page (and not only the preview page as example 1056.aspx) until the content editor logs out. This may be very confusing for content editors when seeing the not published content on a published page.

Edit: On my installation in the MVC mode the template is not being extended with the preview badge.

Comments

Sebastiaan Janssen 31 Jan 2013, 15:50:07

There is a ribbon in the top right corner that says preview mode is on, right?


Andreas Iseli 31 Jan 2013, 15:52:55

Oh sorry to tell you, that one is missing as well. I've read there is a parallel implementation for the mvc preview mode but could not yet detect it in the source.


Sebastiaan Janssen 31 Jan 2013, 15:55:55

You never see the ribbon? I tested it especially (in both webforms and mvc mode) because the implementation was fixed to also support previewing pages that had unpublished parents. So I've seen it work in both Mvc and WebForms mode. What browser(s) are you using?


Andreas Iseli 31 Jan 2013, 16:06:11

You mean the preview badge? No I never see it, even not in the source code of the page. As far as I know it should be added automatically to the HTML with absolute positioning. I've tested FF, IE and Chrome. I'm going to try another clean installation of 6.0.0 and will give you feedback here.


Andreas Iseli 31 Jan 2013, 16:25:40

Same happens with a clean installation and a simple own template. With a webforms-template it works as a charm.


Andreas Iseli 31 Jan 2013, 17:26:58

I've downloaded the newest umbraco source code now and inspected / debugged the mvc part. But I cannot find the part where the preview badge should be added. Who knows where it should be positioned? I'm unfortunately not extremely familiar with the umbraco source code.


Andreas Iseli 05 Feb 2013, 14:11:34

Can please someone point me to the codepart where the ribbon in mvc mode should be populated in preview mode? The i would debug it any further but currently I'm only able to find the codepart for the webforms mode...


Asbjørn Riis-Knudsen 09 Feb 2013, 11:04:07

I just tried Preview mode in MVC with Umbraco 6 as well. I can confirm that no preview banner is shown. I'll try debugging it more when I get the chance.


Asbjørn Riis-Knudsen 09 Feb 2013, 18:42:26

I also tried finding the place in the source where the preview badge is added for MVC views. I can't find it anywhere. I may have missed it though, given my lack of familiarity with the Umbraco source. But I managed to find the code for WebForms easily. It seems that the badge simply isn't being added to MVC pages - though I think you could easily add it manually in the template to work around this issue.


Andreas Iseli 09 Feb 2013, 18:46:29

Thanks for your answer. Yes I could do that, but it would be better to add this functionality to the upcoming release.


Asbjørn Riis-Knudsen 09 Feb 2013, 22:53:28

I have created the following Umbraco helper method, which shows the preview banner when in preview mode: public static class UmbracoHelpers { public static MvcHtmlString PreviewBadge(this UmbracoHelper helper) { if (UmbracoContext.Current.InPreviewMode) { string htmlBadge = String.Format(UmbracoSettings.PreviewBadge, IOHelper.ResolveUrl(SystemDirectories.Umbraco), IOHelper.ResolveUrl(SystemDirectories.UmbracoClient), UmbracoContext.Current.HttpContext.Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path)); return new MvcHtmlString(htmlBadge); } return new MvcHtmlString("");

}

}

Just include it before the body tag, like this @Umbraco.PreviewBadge() </body/>

{code}

This should of course be built-in and automatic, like WebForms, but in the meantime, you can use this. I haven't yet figured out the correct way of injecting this html in MVC automatically, so for now I use this.


Andreas Iseli 13 Feb 2013, 16:52:14

I've integrated your method now as extension and I'm rendering it at the end of the body tag in my master template. Thanks for it. I hope there will be an internal integration for the upcoming release :)


Shannon Deminick 05 Mar 2013, 21:04:15

Yes the preview badge would have never shown in MVC. It will be automatically appended now, however there is a slight 'gotcha' which is that MVC doesn't offer any type of 'pre-render' pipeline so the only way we can parse the html output is to put an output filter on the entire response using an http module, or override the "WriteLiteral" method of the UmbracoTemplatePage (which is what I've done). The 'gotcha' here is that if your page the is rendering the tag isn't a UmbracoViewPage(i.e. @inherits Umbraco.Web.Mvc.UmbracoViewPage) then it will not work. By default all template inherit from UmbracoTemplatePage which does inherit from it (UmbracoViewPage)

I have added your snippet to our HtmlHelper extensions (instead of UmbracoHelper since it's really generating html) just in case people aren't using UmbracoTemplatePage or UmbracoViewPage


Sebastiaan Janssen 04 Apr 2013, 14:23:38

Removing due in 6.1 as this was already implemented in an earlier version, which means it's included in all later versions as well.


cat 01 Jun 2015, 11:58:33

@sebastiaan We discovered today that we have this issue still present even though we have a later version than 6.1 running (6.2.1). Could it be possible that the issue was not entirely fixed, or perhaps, reemerged in a later version? We have umbraco running for a variety of customers, the issue could be replicated on at least 2 different environments which leads me to believe that this is a matter of code.
Could you be so kind as to verify if this issue was indeed fixed in 6.1 and if so, remained fixed? Thanks in advance. Kind regards, Cat.


Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category: UI

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.10.0, 4.11.0, 6.0.0, 4.11.1, 4.11.2, 4.11.3, 4.11.4, 6.0.1, 4.11.5, 6.0.2

Due in version: 4.11.6, 6.0.3

Sprint:

Story Points:

Cycle: