2

What is the difference between the following scenarios:

  • Experience Editor - page in edit mode fetching content from master DB
  • Preview mode - page from master DB
  • Site running from master DB - master DB is used, take publishing restriction and workflow into consideration

I am getting the error "Object reference not set to instance" in the preview mode and everything is working well in EE and site connected the master DB. I need to understand what is different in the preview mode.

It is related to this question: Object reference not set to instance in preview mode for sc_translate

1
  • Yes in preview mode, master db is an active database. about the issue you are facing seems related to Site configuration, in sxa site settings please check you have all valid values for hostname, targethostname, and dictionarydomain. Mar 16 at 14:43

3 Answers 3

1

In addition to @Anton answer,

Sometimes site resolving logic might seem to work in unexpected ways (for example, when opening items in the Experience Editor or in the Preview mode), but in fact, the behavior is affected by special configuration settings that can be changed according to your requirements.

It is recommended to keep the Rendering.SiteResolving setting value at true for any multisite solution in order to ensure that cross-site links are built with the correct parameters.

Here, the Experience Editor and Preview mode is opened in the context of the site defined in the Preview.DefaultSite setting.

In my case, I observed the page preview mode was throwing an error, and when I looked into the Preview.Default setting in Sitecore.config file, it was pointing to website.

So, there are two options you can try here to resolve this issue:

  1. Update the “website” site node start item in Sitecore.config to point to active site/ location or
  2. Update the Preview.DefaultSite mode settings with an active site.

Note:

Please make any updates to Sitecore.config using Sitecore patch file, so that we don’t mess up anything with the default configurations, and down the line didn’t face any issue with Sitecore upgrade as well.

Also, to make sure that items are opened in context of correct site, we must set the Rendering.SiteResolvingMatchCurrentSite setting to true

All configs related to site resolving can be found (/App_Config/Sitecore.config)

Please read more about the site resolving here- https://kb.sitecore.net/articles/986056

Hope it helps!

2

Statement that Preview mode uses master database is only partially true.

Actually, Preview mode simulates what will be in web database after publish from master database.

It means there are a few cases, when Preview mode will not see the item which is in master database such as:

  1. Item is not publishable
  2. Item is not on final workflow state enter link description here
  3. You try to preview item on some date, but item doesn't have publishable version in Publishable from and Publishable to period.

I would suggest you to check the items that are used on your page. Will they be published? Or are there some restrictions?

1

A single Sitecore instance uses multiple websites to manage content delivery, content management, and many other features. However, by default there is only one published website. This website corresponds to the <site name="website"…/> definition in the Sitecore.config file.

In the Sitecore.config file, the Preview.DefaultSite setting determines which website Sitecore displays if a user clicks Preview in the Sitecore Desktop menu. If a user does not have access to the default website, they get an error message.

If you are managing multiple websites then refer to this to manage them.

Configure multiple managed websites

In multisite configuration, the value of Rendering.SiteResolving value set as true at /App_Config/Sitecore.config which helps in site resolving, so cross-site links can be rendered with correct hostname, language, and virtual folder.

The issue is looking like a site configuration that's why it is not resolving the sc_translate in preview mode, as per your other question that you mentioned with this. So verify it and correct it and it will solve the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.