I spent a while banging my head against an issue on a client's site last week. Having finally worked out the subtle misconfiguration of that was causing the bug, I thought I should write it down in case anyone else ever suffers the same problem. I figure if I write this down in enough detail, maybe the next person who suffers a related problem won't have to spend as much time Googling as I did...
was showing the site's homepage rather than the page you had tried to preview. However it was only doing this for some pages on the site. Any page where the "Require Login" security setting had been applied
suffered from the issue. But any page which this was not applied to did not show the problem, and would preview fine. Remove this security setting, and the problem went away. Add it to any page and the problem would appear for that page.
Looking in the Sitecore Logs, each attempt to preview a page that showed the wrong result generated an error message. But not a massively helpful one:
4916 03:37:08 ERROR Item could not be found from query string. [ID is "{9F12B247-9671-45E4-9F15-F27D92B74AF2}".]
The
domain="extranet
in it. Reading around on the internet, when you click the Preview button, Sitecore tries to load the item you selected using the "
So in this case, Sitecore was trying to run the preview as "extranet\anonymous" – which is exactly the security right that we have denied by clicking "Require Login":
So the log error really means "I can't load that item because access is denied". For reasons best known to themselves, the developers who wrote this bit of code seem to have decided that if you can't load an item you should fall back to the homepage item instead of warning the user what's happened.
Changing the
domain
attribute's value to the correct "sitecore" security domain (the one which editorial accounts live in) fixes the issue.