开发者

Get Sitecore "Site" data from web.config in WCF

I understand the issues with WCF and Sitecore because Sitecore.Context would not be available to the WCF request.

But all I'm really looking to do is pass in a site name, and have WCF return some of the attributes of that "site" node from the "sites" section in the web.config.

For example, in the code below I have a site name of "mysitename" for the website "www.mysite.com". How could I programmically get the site's hostname from the 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="fal开发者_如何学JAVAse" />
</sites>

I don't care if it uses prebuilt sitecore functions, or just .net code that is able to read this section of the web.config. Any feedback would help, thanks.


You should be able to use something like:

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

The returned object is supposed to contain the site attributes from the config definition. Don't have Sitecore at my machine right now, so can't check exactly, but you can give it a quick try.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜