"Anonymous requests are not allowed" error appears when openening a page in the preview mode


Description

Opening a page in the preview mode by using a Sitecore client cookies sc_pview_shuser, but not the Preview button might lead to redirection to the login page and cause the following error:

Anonymous requests are not allowed

The issue happens when Sitecore Identity Server is disabled. When the server is disabled, Sitecore relies on the sc_pview_shuser cookie to keep track of the actual user who has triggered the page review. When the Preview button is clicked, Sitecore creates this cookie. Therefore, not using the button to preview the page causes the cookie creation process to be skipped.

Solution

To be able to open a page by using a link without the cookie sc_pview_shuser, set the Preview.AsAnonymous setting to false as follows:

<setting name="Preview.AsAnonymous" value="false" />