Skip Navigation

Kentico Tip: How to Remove the Preview Mode

It's always important to preview content changes before they are published, and Kentico easily provides the ability to do so. While this is a great feature, it also creates an unwanted side effect when you’re working in the Pages application.

Today, I'll explain the best ways to work around this issue.

The Quick Fix

When previewing content pages prior to publishing, if you navigate to the page tab on any page, and then (in the same browser session) visit a live page, you’ll see the following bar at the top:

When you see this, some functionality in templates and web parts may not work properly, so you must close the preview mode before you continue. Easy enough. But because this setting is cookie-based, it will persist each time you reload the Page tab in that browser. This can become annoying when you have a large number of changes in a row that you'd like to preview.

A simple trick to avoid continuously closing preview mode is to implement private browsing mode for your testing window, or better yet, try two different browsers for development and testing.

A Permanent Solution

If you are not using preview mode on your site, another option you have is to simply disable it. If you want to disable preview mode completely, you can do so by adding the following code to PortalTemplate.aspx:

protected override void OnPreInit(EventArgs e)
// If Preview mode (Cookie CMSViewMode == 3), set to Live Site (Cookie CMSViewMode == 0)
if (PortalContext.ViewMode == CMS.PortalEngine.ViewModeEnum.Preview)
PortalContext.ViewMode = CMS.PortalEngine.ViewModeEnum.LiveSite;

You can also put this code directly in a web part, but note that due to the page event lifecycle, it may not work on the first page load because the web part’s PreInit event is called after PortalTemplate’s. Additionally, you may want to add some conditional logic as well, such as checking if the current user is a Global Administrator.

We hope this is a helpful tip! In general, we try to avoid modifying any core Kentico code, but sometimes we do have to make changes to PortalTemplate.aspx in order to add body tags or other custom markup. While it’s not always ideal to do so, it’s nice to know that the option exists if needed.

Have any Kentico-related quandaries you need assistance with? Just ask! Our BlueModus team has been working with the platform for over a decade and would be happy to help.

Interested? Contact Us


Send us a message using the form below or call us at 303.759.2100

Thanks for Reaching Out

We'll get in touch with you soon. In the meantime, please try to remain calm.


1641 California Street #400, Denver, CO 80202
(on California Street between 16th and 17th Streets)


Weekdays from 8:00 AM – 5:00 PM MT

Call Us

If you have any issues, call us at 303.759.2100


Facing the front entrance of the building, there are two keypads:

  1. Using the silver keypad, press 002 to call BlueModus.
  2. A BlueModus colleague will answer and then buzz you in the door.
  3. Walk in straight ahead to the elevator.
  4. Take the elevator to the 4th floor.


There are several nearby parking lots that charge daily or hourly rates, including one directly next to our building. Additionally, there is metered street parking in the area. Typically, credit cards are accepted for all area parking.