Today I wrote a generic routine which should work on all kind of sites. Unfortunatelly this specific code needed to behave differently for site where the "Map Channel names to host header names" feature of MCMS is enabled or not. So I had to find a way to identify this.
MCMS does not expose this flag in a documented API. After some research I identified that the Url of the root channel will look different if the feature is enabled or not.
So implementation of such a check is quite simple:
private bool MapChannelToHostHeaderEnabled()
return ((CmsHttpContext.Current.RootChannel.UrlModePublished == "http://Channels/") ||
(CmsHttpContext.Current.RootChannel.UrlModePublished == "https://Channels/"));
or if you prefer a more flexibel version which can also be used with CmsApplicationContext or from within a workflow event: