Get Sitecore Site data from web.config to WCF

I understand the problems with WCF and Sitecore because Sitecore.Context will not be available for WCF request.

But all I really need to do is pass the site name and return to WCF some attributes of this "site" node from the "sites" section in the web.config file.

For example, in the code below, I have the site name "mysitename" for the website "www.mysite.com". How can I programmatically get the hostname of a site from web.config?

<sites> <site name="mysitename" hostName="www.mysite.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="100MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" /> </sites> 

I don’t care if it uses pre-built sitecore functions or just .net code that can read this section of web.config. Any feedback will help, thanks.

+4
source share
1 answer

You should be able to use something like:

 var site = Sitecore.Configuration.Factory.GetSite(sitename); 

The returned object must contain the site attributes from the configuration definition. I do not have Sitecore on my machine right now, so I can’t check for sure, but you can try it quickly.

+12
source

Source: https://habr.com/ru/post/1347286/


All Articles