How can I get the CurrentSiteID when using the API externally?

Kentico Dev asked on November 5, 2019 21:45

I set up a project using the steps here so I could use the Kentico API in an external project.

Everything works well, but I don't know how to get the proper site ID. I'm using the code below:

activity.ActivitySiteID = SiteContext.CurrentSiteID;

That always returns the global site ID. How do I configure the project to know which specific site to use?

Correct Answer

Peter Mogilnitski answered on November 5, 2019 21:51

You need to use SiteInfoProvider

SiteInfo si = SiteInfoProvider.GetSiteInfo("SiteName");
if (si!= null)
{
    siteID = si.SiteID;
}
2 votesVote for this answer Unmark Correct answer

Recent Answers


Kentico Dev answered on November 5, 2019 21:52

Thanks!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.