+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to obtain site ID

How to obtain site ID

3 posts, 0 answered
  1. Patrick
    Patrick avatar
    3 posts
    Registered:
    22 May 2013
    12 Jun 2013
    Link to this post
    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.
  2. Patrick
    Patrick avatar
    3 posts
    Registered:
    22 May 2013
    13 Jun 2013
    Link to this post
    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"];)
  3. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    08 Dec 2016
    17 Jun 2013
    Link to this post
    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
3 posts, 0 answered