How to obtain site ID

Posted by Community Admin on 04-Aug-2018 18:36

How to obtain site ID

All Replies

Posted by Community Admin on 12-Jun-2013 00:00
Hello,

I am working with SiteFinity 6.0, and have currently established two (2) sites. Each site represents a unique big-picture entity, each of which is already established and lives in a separate database table. I need to create a table that allows me to map each SiteFinity site with one of these entities. My question is how can I obtain the site ID of the site I am currently viewing from a code behind of one of my custom controls? This would obviously be needed to query information from that table.

Also, possibly looking at this from another angle, is there any way to create a site in SiteFinity and apply settings to it? In this case, I could establish a site and simply give it a few key/value settings (e.x. RemoteEntityId -> 34).

Any help is greatly appreciated.
Posted by Community Admin on 13-Jun-2013 00:00
I found the answer to my problem. You can access the current site as follows:

var currentSite = new Telerik.Sitefinity.Multisite.MultisiteContext().CurrentSite;


This has solved my issue with being able to retrieve the site ID, however I would still like to know whether or not you can create a site and store dictionary values along with it? That way when I retrieve the current site I am able to access a dictionary of values I would like to store with each site (for example, CurrentSite.ExtendedValues["SomeProperty"];)
Posted by Community Admin on 17-Jun-2013 00:00
Hello,

Each site in the multisite setup stores only the site related information like site ID, name, domain, etc tough its not a type that can store custom data as the dictionary you refer to. An option is to store the additional properties in a module available only in specific site or in database tables created only for the purpose to save this information. Let me know what properties you want to save and in what is the result to be achieved to see if this can be achieved in other way.

Regards,
Stanislav Velikov
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
This thread is closed