Generating URL for ‘master’ db context of a Sitecore item


We’re posting the content of a page to an external tool for a review, from within our sitecore Preview mode. While doing it, we’re reading the entire html from the url of a sitecore item that is generated using Sitecore.Links.LinkManager

But this always gets the item’s published URL which is always built using ‘web’ db context. Even after appending sc_content=master, doesn’t help as it also yields the web context.



Existing site settings configuration reads something like this, the default one:



We created a new <site> node in the config file. The sole purpose of that <site> entry is to give us the master db context. So we added a new element, but remember to add this element before the default ‘website’ site element like this:


This is one half. The  other half is about using this entry in the links generation. By defaylt Sitecore.Links.Manager will use the default <site> element and hence will form the link using the web db context. To use our custom website entry, we have to call that in our link generation scope. This can be acheived in any of 2 ways.


We can explicitly call out the site name in the querystring if we want to maintain the same domain name like this:





Hope this helps. Do let me know if you have an opinion on this.

About The Author

Leave a Reply